diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2024-06-14 11:52:53 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2024-06-19 18:08:05 +0200 |
| commit | 81ef787a6f41f99f889fd24be94ce0682ea7df75 (patch) | |
| tree | 0b3c24db3237ce13003ee5d5001c88f89a27cb2d /src/quickwidgets/qquickwidget.cpp | |
| parent | d14bf9803e5bb0d736dd272c3abc9f460422ef40 (diff) | |
QQuickWidgets: Don't recreate root item on window change
Previously, QQuickWidgetPrivate::execute() was used in
QQuickWidgetPrivate::handleWindowChange to reset the state of the root
component and reparent it to the new window. This is only performed
if there is a source, presumably to create the new root element from the
latest available one. This however doesn't seem necessary as setting a
new source already calls execute() meaning the current root element is
already based on it. Therefore, it should be sufficient to simply
reparent.
This change fixes QTBUG-126136. When calling setLayout in MyWidget, the
root element is reparented and this leads to
qSendWindowChangeToTextureChildrenRecursively() and ultimatly
handleWindowChange() being called. There the root element get's deleted
and recreated within execute. Back in the user code, this has the
visible effect of breaking the connection that had been created as well
as leaving the pointer to the deleted root element dangling.
This problem was partially hidden in 6.5 and from 6.7.0 onwards by
1bd755465efa27294362925f55306f88f1800936 when it prevented
qSendWindowChangeToTextureChildrenRecursively() from being called from
QWidget::setParent().
Pick-to: 6.8 6.5
Fixes: QTBUG-126136
Change-Id: Id7c820a88f2c0265ea9a3c1e3f02a045356087d5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quickwidgets/qquickwidget.cpp')
| -rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index fda7868c8e..130b7677e6 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -276,9 +276,7 @@ void QQuickWidgetPrivate::handleWindowChange() QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate())); QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate())); - if (!source.isEmpty()) - execute(); - else if (QQuickItem *sgItem = qobject_cast<QQuickItem *>(root)) + if (QQuickItem *sgItem = qobject_cast<QQuickItem *>(root)) sgItem->setParentItem(offscreenWindow->contentItem()); } |
