Don't crash during QApplication construction

The QCoreApplication::init() function calls the virtual
QCoreApplicationPrivate::createEventDispatcher(), which for
QApplication, also creates the plaform integration. Unfortunately, the
Cocoa menubar integration uses qApp before QApplication is constructed,
causing a crash. Circumvent this by using QGuiApplicationPrivate
directly.

Change-Id: Ib36f628641761e70f9e9e39dd23e70e7537a165b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
Bradley T. Hughes 2012-01-11 14:23:05 +01:00 committed by Qt by Nokia
parent 9834b3681f
commit a43986e2a5

View File

@ -45,6 +45,7 @@
#include <QtCore>
#include <QtGui>
#include <private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
@ -441,7 +442,7 @@ QString qt_mac_applicationName()
appName = QCFString::toQString(static_cast<CFStringRef>(string));
if (appName.isEmpty()) {
QString arg0 = qApp->arguments().at(0);
QString arg0 = QGuiApplicationPrivate::instance()->appName();
if (arg0.contains("/")) {
QStringList parts = arg0.split("/");
appName = parts.at(parts.count() - 1);