diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-06-22 14:26:09 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-06-25 06:20:03 +0200 |
commit | 0dbd2dd86389c0705dbe9f518aed12f609ed09a1 (patch) | |
tree | 7cd2d39552cbe9c033f3a4d157033438d3e882da /src/widgets/kernel/qapplication.cpp | |
parent | 75638e258f2ec7857fc989736f1ee9b73eeae035 (diff) |
Skip proxy widgets that can't take focus when (back)tabbing
Fixes regression introduced in b4981f9d4ca914c6ecaa49bfdd69e51806a3671a,
due to which it was possible to back-tab into a widget even though it or
its focusProxy had a NoFocus policy.
As a drive-by, split the complicated if-statement up a bit for improved
readability.
Change-Id: Ib0ac2604076e812e340b11534c23ae8ae958d082
Fixes: QTBUG-76924
Pick-to: 5.15 5.12
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index a2862a56e1..e93eaf5b30 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1952,10 +1952,12 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool // \a next). This is to ensure that we can tab in and out of compound widgets // without getting stuck in a tab-loop between parent and child. QWidget *focusProxy = test->d_func()->deepestFocusProxy(); - - if ((test->focusPolicy() & focus_flag) == focus_flag - && !(next && focusProxy && focusProxy->isAncestorOf(test)) - && !(!next && focusProxy && test->isAncestorOf(focusProxy)) + const bool canTakeFocus = ((focusProxy ? focusProxy->focusPolicy() : test->focusPolicy()) + & focus_flag) == focus_flag; + const bool composites = focusProxy ? (next ? focusProxy->isAncestorOf(test) + : test->isAncestorOf(focusProxy)) + : false; + if (canTakeFocus && !composites && test->isVisibleTo(toplevel) && test->isEnabled() && !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test)) && (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test)) |