From 7f5d41e286e043c5f3061e2eb5a0128102a38c80 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 15 Jan 2021 15:00:01 +0100 Subject: Windows: Fix dialog moving up after closing/reshowing A resize event delivered after closing the platform window was causing the stored frame margins to be cleared. Bail out of QWidgetWindow::updateMargins() if the platform window is null. Pick-to: 5.15 Fixes: QTBUG-79147 Change-Id: Iebbc90c3cccafa209cd720baedf45affb3f3c2b8 Reviewed-by: Richard Moe Gustavsen --- src/widgets/kernel/qwidgetwindow.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index ae1e461d7a..cdc358aca2 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -736,8 +736,12 @@ bool QWidgetWindow::updateSize() void QWidgetWindow::updateMargins() { - const QMargins margins = frameMargins(); + // QTBUG-79147 (Windows): Bail out on resize events after closing a dialog + // and destroying the platform window which would clear the margins. QTLWExtra *te = m_widget->d_func()->topData(); + if (te->window == nullptr || te->window->handle() == nullptr) + return; + const QMargins margins = frameMargins(); te->posIncludesFrame= false; te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom()); m_widget->data->fstrut_dirty = false; -- cgit v1.2.3