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>
This commit is contained in:
parent
d023b300b2
commit
51767affb3
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user