diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-11-22 15:36:29 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-11-24 13:45:00 +0000 |
commit | 5ea88ae239883d8a2b161df14c16d8630c9dc782 (patch) | |
tree | 201213b60fbdf4018e9eb12d07b253866773cda7 /src/widgets/kernel/qapplication.cpp | |
parent | 1f81ba45eeb1a0d233bb2515c048da8743c91f6f (diff) |
Replace manual parent traversal in isWindowBlocked with use of isAncestorOf
Change-Id: I208d70a61e407069277339b3997c82921ab1b39b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 358838b4e9..b0e7293b88 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2455,28 +2455,20 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin for (int i = 0; i < modalWindowList.count(); ++i) { QWindow *modalWindow = modalWindowList.at(i); - { - // check if the modal window is our window or a (transient) parent of our window - QWindow *w = window; - while (w) { - if (w == modalWindow) { - *blockingWindow = 0; - return false; - } - QWindow *p = w->parent(); - if (!p) - p = w->transientParent(); - w = p; - } - - // Embedded in-process windows are not visible in normal parent-child chain, - // so check the native parent chain, too. - const QPlatformWindow *platWin = window->handle(); - const QPlatformWindow *modalPlatWin = modalWindow->handle(); - if (platWin && modalPlatWin && platWin->isEmbedded(modalPlatWin)) - return false; + // A window is not blocked by another modal window if the two are + // the same, or if the window is a child of the modal window. + if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) { + *blockingWindow = 0; + return false; } + // Embedded windows are not visible in normal parent-child chain, + // so check the native parent chain, too. + const QPlatformWindow *platWin = window->handle(); + const QPlatformWindow *modalPlatWin = modalWindow->handle(); + if (platWin && modalPlatWin && platWin->isEmbedded(modalPlatWin)) + return false; + Qt::WindowModality windowModality = modalWindow->modality(); QWidgetWindow *modalWidgetWindow = qobject_cast<QWidgetWindow *>(modalWindow); if (windowModality == Qt::NonModal) { |