From 300d984bdb9b53bd4c1adba0ec11ed188ca4b57c Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Fri, 6 Jul 2012 21:00:51 +0530 Subject: [PATCH] qpa: Fix crash when native interface is null QPlatformNativeInterface is optional. Change-Id: Iae2a6de63fc8a36deb6059047a0d7f05defb6b5c Reviewed-by: Friedemann Kleint --- src/gui/kernel/qguiapplication.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 0cc4ef65d4..fd7e32e96f 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -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