From f79f7a3b6d80a29baad5c5cb1bf68bb01045c7c7 Mon Sep 17 00:00:00 2001 From: Anu Aliyas Date: Wed, 30 Aug 2023 12:31:14 +0200 Subject: Delay the graphics API setup calls - The initialization process sets up the graphics API before the main is invoked and hence the qputenv calls have no effect. - Delayed the graphic API setup calls so that it will consider the value set by qputenv calls as well. Fixes: QTBUG-116159 Pick-to: 6.6 Change-Id: I1e9dde7f65c214a7d5963dbba12f41b8feba925f Reviewed-by: Peter Varga --- src/core/api/qtwebenginecoreglobal.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/core/api/qtwebenginecoreglobal.cpp') diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp index 7d547cb51..a379a8dfe 100644 --- a/src/core/api/qtwebenginecoreglobal.cpp +++ b/src/core/api/qtwebenginecoreglobal.cpp @@ -48,6 +48,14 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize() #ifdef Q_OS_WIN32 qputenv("QT_D3DCREATE_MULTITHREADED", "1"); #endif + auto api = QQuickWindow::graphicsApi(); + if (api != QSGRendererInterface::OpenGL +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) + && api != QSGRendererInterface::Vulkan && api != QSGRendererInterface::Metal + && api != QSGRendererInterface::Direct3D11 +#endif + ) + QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL); // No need to override the shared context if QApplication already set one (e.g with Qt::AA_ShareOpenGLContexts). if (!qt_gl_global_share_context()) { @@ -109,14 +117,6 @@ static void initialize() #if QT_CONFIG(opengl) && !defined(Q_OS_MACOS) // QCoreApplication is not yet instantiated, ensuring the call will be deferred qAddPreRoutine(QtWebEngineCore::initialize); - auto api = QQuickWindow::graphicsApi(); - if (api != QSGRendererInterface::OpenGL -#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) - && api != QSGRendererInterface::Vulkan - && api != QSGRendererInterface::Metal && api != QSGRendererInterface::Direct3D11 -#endif - ) - QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL); #endif // QT_CONFIG(opengl) } -- cgit v1.2.3