summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qsurfaceformat.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2016-10-19 10:49:21 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-21 14:45:30 +0000
commitf773ddd026a6227cdb754dea4a5fe0a25137033f (patch)
tree7d5152e2d78bc9dd40588bcfa700b15db1309eae /src/gui/kernel/qsurfaceformat.cpp
parent10b9321c1dc19236620ba20bdf54cae73891d1ef (diff)
Fix when calling QSurfaceFormat::setDefaultFormat before Q*Application
Fixes a regression introduced in commit 51767affb. QOpenGLContext::globalShareContext requires a QGuiApplication to exist. This wasn't required so far. Task-number: QTBUG-56614 Change-Id: I07bcf434fca536c4dc50feee7ea17eb541fd589a Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src/gui/kernel/qsurfaceformat.cpp')
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 109ba8e610..d19690891f 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -36,6 +36,7 @@
#include <QtCore/qatomic.h>
#include <QtCore/QDebug>
#include <QOpenGLContext>
+#include <QtGui/qguiapplication.h>
#ifdef major
#undef major
@@ -760,10 +761,13 @@ Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format)
void QSurfaceFormat::setDefaultFormat(const QSurfaceFormat &format)
{
#ifndef QT_NO_OPENGL
- QOpenGLContext *globalContext = QOpenGLContext::globalShareContext();
- if (globalContext && globalContext->isValid()) {
- qWarning("Warning: Setting a new default format with a different version or profile after "
- "the global shared context is created may cause issues with context sharing.");
+ if (qApp) {
+ QOpenGLContext *globalContext = QOpenGLContext::globalShareContext();
+ if (globalContext && globalContext->isValid()) {
+ qWarning("Warning: Setting a new default format with a different version or profile "
+ "after the global shared context is created may cause issues with context "
+ "sharing.");
+ }
}
#endif
*qt_default_surface_format() = format;