diff options
author | Sze Howe Koh <szehowe.koh@gmail.com> | 2021-07-24 22:12:36 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-04 05:25:10 +0000 |
commit | 6d5c61bd7c15f81c81c08e84e09b25180782d98f (patch) | |
tree | 8eb110890f319b908babb52235026fcb543a63cd | |
parent | 37b4c2c2c7da0aa8fe67676e49fb92a34e725e92 (diff) |
QPixmap: Fix crash if created without gui app in secondary thread
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
Change-Id: I93c983a3d6c271b0a19dfd0384862fc151459029
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
(cherry picked from commit ee5077daf59f24ca535302799ad718935e6bc4b8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/gui/image/qpixmap.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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"); |