diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/kernel/qwidget_qpa.cpp | 6 | ||||
-rw-r--r-- | src/widgets/kernel/qwindowcontainer.cpp | 19 | ||||
-rw-r--r-- | src/widgets/kernel/qwindowcontainer_p.h | 1 |
3 files changed, 22 insertions, 4 deletions
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 18045e3b09..3c4985591e 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -53,6 +53,7 @@ #include <qpa/qplatformintegration.h> #include "QtGui/private/qwindow_p.h" #include "QtGui/private/qguiapplication_p.h" +#include <private/qwindowcontainer_p.h> #include <qpa/qplatformcursor.h> #include <QtGui/QGuiApplication> @@ -267,8 +268,11 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); // Reparenting toplevel to child - if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) + if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) { + if (extra && extra->hasWindowContainer) + QWindowContainer::toplevelAboutToBeDestroyed(q); q->destroy(); + } adjustFlags(f, q); data.window_flags = f; diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 6914f64f8e..7c319c5095 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -300,15 +300,28 @@ static void qwindowcontainer_traverse(QWidget *parent, qwindowcontainer_traverse } } +void QWindowContainer::toplevelAboutToBeDestroyed(QWidget *parent) +{ + if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)) { + d->window->setParent(&d->fakeParent); + } + qwindowcontainer_traverse(parent, toplevelAboutToBeDestroyed); +} + void QWindowContainer::parentWasChanged(QWidget *parent) { if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)) { if (d->window->parent()) { d->updateUsesNativeWidgets(); d->markParentChain(); - d->window->setParent(d->usesNativeWidgets - ? parent->windowHandle() - : parent->window()->windowHandle()); + QWidget *toplevel = d->usesNativeWidgets ? parent : parent->window(); + if (!toplevel->windowHandle()) { + QWidgetPrivate *tld = static_cast<QWidgetPrivate *>(QWidgetPrivate::get(toplevel)); + tld->createTLExtra(); + tld->createTLSysExtra(); + Q_ASSERT(toplevel->windowHandle()); + } + d->window->setParent(toplevel->windowHandle()); d->updateGeometry(); } } diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h index e2446bef42..a21f9bd35a 100644 --- a/src/widgets/kernel/qwindowcontainer_p.h +++ b/src/widgets/kernel/qwindowcontainer_p.h @@ -57,6 +57,7 @@ public: explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = 0, Qt::WindowFlags f = 0); ~QWindowContainer(); + static void toplevelAboutToBeDestroyed(QWidget *parent); static void parentWasChanged(QWidget *parent); static void parentWasMoved(QWidget *parent); static void parentWasRaised(QWidget *parent); |