Similar to c4cfeb6bbf8d, avoid crashes due to bad references.

Make sure argc is always valid when QCoreApplication access it, by keeping
it as a reference to argc from main.

This is similar to PR #242.