@@ -301,25 +301,24 @@ void RenderModeRequest::apply()
301301 if (connection)
302302 disconnect (connection);
303303
304- #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
305- // crashes in qrhigles2..bindShaderResources sometimes
306- return ;
307- #endif
308-
309304 if (window && window->rendererInterface ()->graphicsApi () != QSGRendererInterface::OpenGL)
310305 return ;
311306
312307 if (window) {
313- emit aboutToCleanSceneGraph ();
314308 const QByteArray mode = renderModeToString (RenderModeRequest::mode);
315309 QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get (window);
316- QMetaObject::invokeMethod (window, " cleanupSceneGraph" , Qt::DirectConnection);
317310#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
318- winPriv->visualizationMode = mode;
311+ QObject::connect (window.get (), &QQuickWindow::beforeSynchronizing, this , [this , winPriv, mode]() {
312+ emit aboutToCleanSceneGraph ();
313+ QMetaObject::invokeMethod (window, " cleanupSceneGraph" , Qt::DirectConnection);
314+ winPriv->visualizationMode = mode;
315+ emit sceneGraphCleanedUp (); }, static_cast <Qt::ConnectionType>(Qt::DirectConnection | Qt::SingleShotConnection));
319316#else
317+ emit aboutToCleanSceneGraph ();
318+ QMetaObject::invokeMethod (window, " cleanupSceneGraph" , Qt::DirectConnection);
320319 winPriv->customRenderMode = mode;
321- #endif
322320 emit sceneGraphCleanedUp ();
321+ #endif
323322 }
324323
325324 QMetaObject::invokeMethod (this , " preFinished" , Qt::QueuedConnection);
0 commit comments