qpa: Fix crash when native interface is null
authorGirish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Fri, 6 Jul 2012 15:30:51 +0000 (21:00 +0530)
committerQt by Nokia <qt-info@nokia.com>
Mon, 9 Jul 2012 09:49:07 +0000 (11:49 +0200)
QPlatformNativeInterface is optional.

Change-Id: Iae2a6de63fc8a36deb6059047a0d7f05defb6b5c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/gui/kernel/qguiapplication.cpp

index 0cc4ef6..fd7e32e 100644 (file)
@@ -718,14 +718,15 @@ static void init_platform(const QString &pluginArgument, const QString &platform
     // Set arguments as dynamic properties on the native interface as
     // boolean 'foo' or strings: 'foo=bar'
     if (!arguments.isEmpty()) {
-        QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface();
-        foreach (const QString &argument, arguments) {
-            const int equalsPos = argument.indexOf(QLatin1Char('='));
-            const QByteArray name =
-                equalsPos != -1 ? argument.left(equalsPos).toUtf8() : argument.toUtf8();
-            const QVariant value =
-                equalsPos != -1 ? QVariant(argument.mid(equalsPos + 1)) : QVariant(true);
-            nativeInterface->setProperty(name.constData(), value);
+        if (QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface()) {
+            foreach (const QString &argument, arguments) {
+                const int equalsPos = argument.indexOf(QLatin1Char('='));
+                const QByteArray name =
+                    equalsPos != -1 ? argument.left(equalsPos).toUtf8() : argument.toUtf8();
+                const QVariant value =
+                    equalsPos != -1 ? QVariant(argument.mid(equalsPos + 1)) : QVariant(true);
+                nativeInterface->setProperty(name.constData(), value);
+            }
         }
     }
 #endif