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/qsurfaceformat.cpp') 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