From bde1e6718385c4c7c92bfda9ee4b52b99ff92214 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 6 Feb 2014 08:37:58 +0100 Subject: [PATCH] Android: Fix crash when using images in QML Because qtdeclarative was merged back from stable and qtbase is still lagging behind, they have become unsynchronized, causing crashes when trying to get the device name from the platform plugin and failing. To work around this until the merge goes through, I've added a simple guard. Task-number: QTBUG-36658 Change-Id: Ibc399ed325a1fbdeccad85ed8d4841edb7b2ba5d Reviewed-by: BogDan Vatra Reviewed-by: Frederik Gladhorn --- src/quick/scenegraph/util/qsgatlastexture.cpp | 7 ++++--- src/quick/scenegraph/util/qsgtexture.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp index d080c5919..e6a2096c8 100644 --- a/src/quick/scenegraph/util/qsgatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgatlastexture.cpp @@ -148,9 +148,10 @@ Atlas::Atlas(const QSize &size) #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) QString *deviceName = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("AndroidDeviceName")); - static bool wrongfullyReportsBgra8888Support = deviceName->compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0 - || deviceName->compare(QStringLiteral("samsung SM-T210"), Qt::CaseInsensitive) == 0 - || deviceName->compare(QStringLiteral("samsung SM-T215"), Qt::CaseInsensitive) == 0; + static bool wrongfullyReportsBgra8888Support = deviceName != 0 + && (deviceName->compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0 + || deviceName->compare(QStringLiteral("samsung SM-T210"), Qt::CaseInsensitive) == 0 + || deviceName->compare(QStringLiteral("samsung SM-T215"), Qt::CaseInsensitive) == 0); #else static bool wrongfullyReportsBgra8888Support = false; #endif diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index ae1bec3f4..b738896a6 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -684,9 +684,10 @@ void QSGPlainTexture::bind() #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) QString *deviceName = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("AndroidDeviceName")); - static bool wrongfullyReportsBgra8888Support = deviceName->compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0 - || deviceName->compare(QStringLiteral("samsung SM-T210"), Qt::CaseInsensitive) == 0 - || deviceName->compare(QStringLiteral("samsung SM-T215"), Qt::CaseInsensitive) == 0; + static bool wrongfullyReportsBgra8888Support = deviceName != 0 + && (deviceName->compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0 + || deviceName->compare(QStringLiteral("samsung SM-T210"), Qt::CaseInsensitive) == 0 + || deviceName->compare(QStringLiteral("samsung SM-T215"), Qt::CaseInsensitive) == 0); #else static bool wrongfullyReportsBgra8888Support = false; #endif -- 2.34.1