summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/image/qnativeimage.cpp2
-rw-r--r--src/gui/kernel/qwindow.cpp11
-rw-r--r--src/widgets/util/qcolormap.cpp7
3 files changed, 15 insertions, 5 deletions
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 09cdf41399..356bdc09e4 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -64,6 +64,8 @@ QNativeImage::~QNativeImage()
QImage::Format QNativeImage::systemFormat()
{
+ if (!QGuiApplication::primaryScreen())
+ return QImage::Format_Invalid;
return QGuiApplication::primaryScreen()->handle()->format();
}
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index fd9e0ad61b..13da58e391 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -159,10 +159,6 @@ QWindow::QWindow(QScreen *targetScreen)
d->screen = targetScreen;
if (!d->screen)
d->screen = QGuiApplication::primaryScreen();
-
- //if your applications aborts here, then chances are your creating a QWindow before the
- //screen list is populated.
- Q_ASSERT(d->screen);
d->init();
}
@@ -232,6 +228,13 @@ QWindow::~QWindow()
void QWindowPrivate::init()
{
Q_Q(QWindow);
+
+ // If your application aborts here, you are probably creating a QWindow
+ // before the screen list is populated.
+ if (!screen) {
+ qFatal("Cannot create window: no screens available");
+ exit(1);
+ }
QObject::connect(screen, SIGNAL(destroyed(QObject*)), q, SLOT(screenDestroyed(QObject*)));
QGuiApplicationPrivate::window_list.prepend(q);
}
diff --git a/src/widgets/util/qcolormap.cpp b/src/widgets/util/qcolormap.cpp
index 03ee8a395e..decfd7bd2c 100644
--- a/src/widgets/util/qcolormap.cpp
+++ b/src/widgets/util/qcolormap.cpp
@@ -66,7 +66,12 @@ static QColormapPrivate *screenMap = 0;
void QColormap::initialize()
{
screenMap = new QColormapPrivate;
-
+ if (!QGuiApplication::primaryScreen()) {
+ qWarning("no screens available, assuming 24-bit color");
+ screenMap->depth = 24;
+ screenMap->mode = QColormap::Direct;
+ return;
+ }
screenMap->depth = QGuiApplication::primaryScreen()->depth();
if (screenMap->depth < 8) {
screenMap->mode = QColormap::Indexed;