diff options
author | Alexandru Croitor <alexandru.croitor@theqtcompany.com> | 2016-02-11 16:28:57 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2016-10-13 15:38:05 +0000 |
commit | 51767affb380eea5961637f07a2e881b93b6fea5 (patch) | |
tree | a3c5c80142c2ac1c8c73fc71f6d3b47f92a30988 /src/gui/kernel/qsurfaceformat.cpp | |
parent | d023b300b26a9db3cf4dbbe31c1cc5726fe277d7 (diff) |
Show warning when setting new default QSurfaceFormat
If a global shared context is created, and afterwards a new default
QSurfaceFormat with a different version or profile is set, it can
lead to issues with context sharing.
The documentation for QSurfaceFormat::setDefaultFormat mentions
this. It would be helpful to actually show a warning in case it
happens.
Change-Id: I71f7ce95496e1ecbfc6a0c7d7bed146ef8dc351e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/kernel/qsurfaceformat.cpp')
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index d078336d73..18fde5716b 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -35,6 +35,7 @@ #include <QtCore/qatomic.h> #include <QtCore/QDebug> +#include <QOpenGLContext> #ifdef major #undef major @@ -758,6 +759,11 @@ Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format) */ void QSurfaceFormat::setDefaultFormat(const QSurfaceFormat &format) { + 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."); + } *qt_default_surface_format() = format; } |