From ee5077daf59f24ca535302799ad718935e6bc4b8 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sat, 24 Jul 2021 22:12:36 +0800 Subject: QPixmap: Fix crash if created without gui app in secondary thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The thread checking in in_pixmap_thread_test() is only safe, and only makes sense, if we have a QGuiApplication. If we only have QCoreApplication, only null QPixmaps may be created anyway, so threading makes no difference. Fixes: QTBUG-95358 Pick-to: 6.2 Change-Id: I93c983a3d6c271b0a19dfd0384862fc151459029 Reviewed-by: Tor Arne Vestbø Reviewed-by: Sze Howe Koh --- src/gui/image/qpixmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/image/qpixmap.cpp') diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 3d46dc4a6b..b1be8ff408 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -82,7 +82,7 @@ static bool qt_pixmap_thread_test() return false; } - if (qApp->thread() != QThread::currentThread()) { + if (QGuiApplicationPrivate::instance() && qApp->thread() != QThread::currentThread()) { bool fail = false; if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) { printf("Platform plugin does not support threaded pixmaps!\n"); -- cgit v1.2.3