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
Pick-to: 6.2
Change-Id: I93c983a3d6c271b0a19dfd0384862fc151459029
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
bb10
Sze Howe Koh 2021-07-24 22:12:36 +08:00 committed by Eirik Aavitsland
parent ae8e96d4c2
commit ee5077daf5
1 changed files with 1 additions and 1 deletions

View File

@ -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");