widgets: Send Window{AboutToChange}Internal when top level used RHI

When calling setParent for a top-level widget that used RHI it's
not enough to check if the widget's parent used RHI, as that's
always going to be false.

Missing this results in not sending textureChildren events for the
reparented widget.

Amends eb4cb719257d3b57cd801273d4011579d8c81714

Fixes: QTBUG-129299
Pick-to: 6.8.0
Change-Id: I632d8d63ec56243cd6da2b196ad9651c28128f0b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 0704eff5617a100634c58177c83ed0d90b6f5525)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Inho Lee 2024-09-27 10:33:59 +02:00 committed by Qt Cherry-pick Bot
parent 65a48e7ab8
commit 1befc288c0

View File

@ -10757,8 +10757,9 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
// texture-based widgets need a pre-notification when their associated top-level window changes
// This is not under the wasCreated/newParent conditions above in order to also play nice with QDockWidget.
const bool oldParentUsesRhiFlush = oldParentWithWindow ? oldParentWithWindow->d_func()->usesRhiFlush : false;
if (oldParentUsesRhiFlush && ((!parent && parentWidget()) || (parent && parent->window() != oldtlw)))
const bool oldWidgetUsesRhiFlush = oldParentWithWindow ? oldParentWithWindow->d_func()->usesRhiFlush
: oldtlw->d_func()->usesRhiFlush;
if (oldWidgetUsesRhiFlush && ((!parent && parentWidget()) || (parent && parent->window() != oldtlw)))
qSendWindowChangeToTextureChildrenRecursively(this, QEvent::WindowAboutToChangeInternal);
// If we get parented into another window, children will be folded
@ -10839,7 +10840,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
// texture-based widgets need another event when their top-level window
// changes (more precisely, has already changed at this point)
if (oldParentUsesRhiFlush && oldtlw != window())
if (oldWidgetUsesRhiFlush && oldtlw != window())
qSendWindowChangeToTextureChildrenRecursively(this, QEvent::WindowChangeInternal);
if (!wasCreated) {