From 373c08d03d39b6933a16a5b839aa7ae271cede42 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 3 Aug 2023 12:00:39 +0200 Subject: [PATCH] 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 --- src/widgets/kernel/qwidget.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index da7fae2af8..11959688cb 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -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(); } } }