diff options
authorEirik Aavitsland <>2017-10-31 13:46:32 +0100
committerEirik Aavitsland <>2017-11-16 20:59:14 +0000
commit77ee9bd1d3917b2bb1e442433ef0189e9e281e51 (patch)
parentce08318a46164172eaa72f4436cddf7f69ce9e1c (diff)
QPixmap without QGuiApplication: do not crash, terminate gracefully
Any attempt to create a non-null QPixmap in a QCoreApplication-based app would give a hard crash without a warning. This commit adds a check and instead calls qFatal with an explanatory message. This was originally fixed in Qt 4 (ref. QTBUG-17873) but that was lost in the migration to Qt 5. Note that this fix still allows null QPixmaps to be created under QCoreApplication, since that has worked in all Qt 5 versions. Task-number: QTBUG-53572 Task-number: QTBUG-64125 Change-Id: I60ae29b90f1bd3663aeed2ce88dc1690fe66552c Reviewed-by: Lars Knoll <>
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp
index 00c21a5f54..b3b9f79fb1 100644
--- a/src/gui/image/qplatformpixmap.cpp
+++ b/src/gui/image/qplatformpixmap.cpp
@@ -58,6 +58,9 @@ QT_BEGIN_NAMESPACE
QPlatformPixmap *QPlatformPixmap::create(int w, int h, PixelType type)
+ if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration()))
+ qFatal("QPlatformPixmap: QGuiApplication required");
QPlatformPixmap *data = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(static_cast<QPlatformPixmap::PixelType>(type));
data->resize(w, h);
return data;