From 51767affb380eea5961637f07a2e881b93b6fea5 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 11 Feb 2016 16:28:57 +0100 Subject: 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 --- src/gui/kernel/qsurfaceformat.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gui/kernel') 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 #include +#include #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; } -- cgit v1.2.3 From d71bb504a635b51a85f3ccd919e0d77f869e50a8 Mon Sep 17 00:00:00 2001 From: hjk Date: Sun, 16 Oct 2016 13:26:30 +0200 Subject: Fix QtGui compilation without OpenGL Change-Id: I2a9f8bde7d2ba672e4e664ff731a3272a6def516 Reviewed-by: Laszlo Agocs --- src/gui/kernel/qsurfaceformat.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 18fde5716b..109ba8e610 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -759,11 +759,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."); } +#endif *qt_default_surface_format() = format; } -- cgit v1.2.3