Fix texture-based non-native child of a non-texture-based native child

Another one in the series of problems around having texture-based and
regular widgets in hierarchies where some widgets are native and some
are not.

Pick-to: 6.6 6.5
Fixes: QTBUG-115652
Task-number: QTBUG-108344
Task-number: QTBUG-113557
Change-Id: I34306503cb17ccb915b90168ec3f39e209f668e5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2023-08-03 12:00:39 +02:00
parent 55c79dcc25
commit 373c08d03d

View File

@ -10860,11 +10860,19 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
if (q_evaluateRhiConfig(this, nullptr, &surfaceType)) {
const bool wasUsingRhiFlush = newtlw->d_func()->usesRhiFlush;
newtlw->d_func()->usesRhiFlush = true;
bool recreate = false;
if (QWindow *w = newtlw->windowHandle()) {
if (w->surfaceType() != surfaceType || !wasUsingRhiFlush) {
newtlw->destroy();
newtlw->create();
}
if (w->surfaceType() != surfaceType || !wasUsingRhiFlush)
recreate = true;
}
// QTBUG-115652: Besides the toplevel the nativeParentWidget()'s QWindow must be checked as well.
if (QWindow *w = d->windowHandle(QWidgetPrivate::WindowHandleMode::Closest)) {
if (w->surfaceType() != surfaceType)
recreate = true;
}
if (recreate) {
newtlw->destroy();
newtlw->create();
}
}
}