From 2e496e93225503c8af068e53294c5eb13aa3bfd7 Mon Sep 17 00:00:00 2001 From: Mauro Persano Date: Thu, 29 Mar 2018 10:37:25 -0300 Subject: [PATCH] Windows: handle multiple transient children when closing windows On Windows, we must update the transient children of a window that's about to be destroyed or its transient children will be destroyed as well. This is already being done in the case of a single transient child, but there are still problems when there are more than one. Change-Id: Ib0de6767bf43dca508ecdb87cbdfedb59e9146e8 Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowswindow.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 9fff4b5e429..9872b6b4e00 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1161,23 +1161,19 @@ void QWindowsWindow::fireExpose(const QRegion ®ion, bool force) QWindowSystemInterface::handleExposeEvent(window(), region); } -static inline QWindow *findTransientChild(const QWindow *parent) -{ - foreach (QWindow *w, QGuiApplication::topLevelWindows()) - if (w->transientParent() == parent) - return w; - return 0; -} - void QWindowsWindow::destroyWindow() { qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() << m_data.hwnd; if (m_data.hwnd) { // Stop event dispatching before Window is destroyed. setFlag(WithinDestroy); // Clear any transient child relationships as Windows will otherwise destroy them (QTBUG-35499, QTBUG-36666) - if (QWindow *transientChild = findTransientChild(window())) - if (QWindowsWindow *tw = QWindowsWindow::windowsWindowOf(transientChild)) - tw->updateTransientParent(); + const auto tlw = QGuiApplication::topLevelWindows(); + for (QWindow *w : tlw) { + if (w->transientParent() == window()) { + if (QWindowsWindow *tw = QWindowsWindow::windowsWindowOf(w)) + tw->updateTransientParent(); + } + } QWindowsContext *context = QWindowsContext::instance(); if (context->windowUnderMouse() == window()) context->clearWindowUnderMouse();