@@ -35,29 +35,45 @@ void DebuggingController::SetSceneGraphVisualizer(const QString &visualizer)
35 Q_FOREACH (QWindow *window, QGuiApplication::allWindows()) {
35 Q_FOREACH (QWindow *window, QGuiApplication::allWindows()) {
36 QQuickWindow* qquickWindow = qobject_cast<QQuickWindow*>(window);
36 QQuickWindow* qquickWindow = qobject_cast<QQuickWindow*>(window);
37 if (qquickWindow) {
37 if (qquickWindow) {
38− QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(qquickWindow);
39− winPriv->customRenderMode = visualizer.toLatin1();
40− qquickWindow->update();
42#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
39#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
43 // Qt does some performance optimizations that break custom render modes.
40 // Qt does some performance optimizations that break custom render modes.
44 // Thus the optimizations are only applied if there is no custom render mode set.
41 // Thus the optimizations are only applied if there is no custom render mode set.
45 // So we need to make the scenegraph recheck whether a custom render mode is set.
42 // So we need to make the scenegraph recheck whether a custom render mode is set.
46 // We do this by simply recreating the renderer.
43 // We do this by simply recreating the renderer.
47−
44+ QMutexLocker lock(&m_renderModeMutex);
48− QQuickItemPrivate *contentPriv = QQuickItemPrivate::get(qquickWindow->contentItem());
45+ m_pendingRenderMode = visualizer;
49− QSGNode *rootNode = contentPriv->itemNode();
46+ connect(qquickWindow, &QQuickWindow::beforeSynchronizing, this, &DebuggingController::applyRenderMode, Qt::DirectConnection);
50− while (rootNode->parent())
47+#else
51− rootNode = rootNode->parent();
48+ QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(qquickWindow);
52−
49+ winPriv->customRenderMode = visualizer.toLatin1();
53− delete winPriv->renderer;
54− winPriv->renderer = winPriv->context->createRenderer();
55− winPriv->renderer->setRootNode(static_cast<QSGRootNode *>(rootNode));
51+ qquickWindow->update();
56+void DebuggingController::applyRenderMode() {
57+ QQuickWindow *qquickWindow = qobject_cast<QQuickWindow*>(sender());
59+ QMutexLocker lock(&m_renderModeMutex);
60+ disconnect(qquickWindow, &QQuickWindow::beforeSynchronizing, this, &DebuggingController::applyRenderMode);
63+#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
64+ QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(qquickWindow);
65+ QQuickItemPrivate *contentPriv = QQuickItemPrivate::get(qquickWindow->contentItem());
66+ QSGNode *rootNode = contentPriv->itemNode();
67+ while (rootNode->parent())
68+ rootNode = rootNode->parent();
70+ winPriv->customRenderMode = m_pendingRenderMode.toLatin1();
71+ delete winPriv->renderer;
72+ winPriv->renderer = winPriv->context->createRenderer();
73+ winPriv->renderer->setRootNode(static_cast<QSGRootNode *>(rootNode));
61void DebuggingController::SetSlowAnimations(bool slowAnimations)
77void DebuggingController::SetSlowAnimations(bool slowAnimations)
63 QUnifiedTimer::instance()->setSlowModeEnabled(slowAnimations);
79 QUnifiedTimer::instance()->setSlowModeEnabled(slowAnimations);