From a3a79fefe65ec12c4c34a69885c2d23d79538a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 4 Mar 2011 10:29:46 +0100 Subject: Fail in a nicer way when QPixmap is used in a non-GUI application. Show same fatal message as when trying to instantiate a QWidget. Task-number: QTBUG-17873 Reviewed-by: Gunnar Sletta --- src/gui/image/qpixmap.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index f896572..71fb079 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -112,8 +112,13 @@ void QPixmap::init(int w, int h, Type type) init(w, h, int(type)); } +extern QApplication::Type qt_appType; + void QPixmap::init(int w, int h, int type) { + if (qt_appType == QApplication::Tty) + qFatal("QPixmap: Cannot create a QPixmap when no GUI is being used"); + if ((w > 0 && h > 0) || type == QPixmapData::BitmapType) data = QPixmapData::create(w, h, (QPixmapData::PixelType) type); else -- cgit v0.12