From ff2e9a17e7583fe18b9ac3527e4aab2a6b395174 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 26 Sep 2017 18:08:25 +0200 Subject: Fix crash when reparenting window container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWindowContainer assumed that a widget could never change from native to non-native. This is not a fact when the window container is reparented to toplevel and back. In this case, usesNativeWidgets would be stuck at true, and parentWasChanged() would go down the native widget path, triggering an assert. The solution is to always recalculate the usesNativeWidgets bool. Task-number: QTBUG-63168 Change-Id: I88178259878ace9eb5de2ee45ff5e69b170da71c Reviewed-by: Laszlo Agocs Reviewed-by: Richard Moe Gustavsen Reviewed-by: Błażej Szczygieł --- src/widgets/kernel/qwindowcontainer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index bffc1f45f2..56114350d2 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -89,7 +89,7 @@ public: void updateUsesNativeWidgets() { - if (usesNativeWidgets || window->parent() == 0) + if (window->parent() == 0) return; Q_Q(QWindowContainer); if (q->internalWinId()) { @@ -97,6 +97,7 @@ public: usesNativeWidgets = true; return; } + bool nativeWidgetSet = false; QWidget *p = q->parentWidget(); while (p) { if (false @@ -108,11 +109,12 @@ public: #endif ) { q->winId(); - usesNativeWidgets = true; + nativeWidgetSet = true; break; } p = p->parentWidget(); } + usesNativeWidgets = nativeWidgetSet; } void markParentChain() { -- cgit v1.2.3