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.

Fixes: QTBUG-115652
Task-number: QTBUG-108344
Task-number: QTBUG-113557
Change-Id: I34306503cb17ccb915b90168ec3f39e209f668e5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 373c08d03d39b6933a16a5b839aa7ae271cede42)
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Laszlo Agocs 2023-08-03 12:00:39 +02:00
parent 3e1a7eeabb
commit 3e09f3abbb

View File

@ -10865,15 +10865,23 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
// problematic when it comes to large widget trees.
if (q_evaluateRhiConfig(this, nullptr, &surfaceType)) {
newtlw->d_func()->usesRhiFlush = true;
bool recreate = false;
if (QWindow *w = newtlw->windowHandle()) {
if (w->surfaceType() != surfaceType) {
if (w->surfaceType() != surfaceType)
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();
}
}
}
}
}
void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
{