summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-10-16 11:31:45 +0200
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-10-20 11:42:59 +0200
commite260e1bcaef123c8250f019b197da10c353eff33 (patch)
treeda7ea8d9b486226b75a469a01a5a6622ff996101 /src
parent0f98d36ff6f01a91f32e9c3359882b6a856da8a0 (diff)
Always report focusObjectChanged on QWidget::clearFocus()
The focusObject() of a QWidgetWindow is based on the focusWidget() of the top level widget of the window, which is resolved through the focus_child chain of the widget. This is not the same thing as the focusWidget of the application. The hasFocus() function of a QWidget queries the latter, so we can't put the focusObjectChanged signal inside hasFocus() when we unconditionally clear the focus_child chain (and hence the focusObject) earlier in the function. Change-Id: Iae39da5d6031d22b21e9dc9f18e5fe6e6fd11a5c Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qwidget.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index e7d33d3bd8..5529f8f72c 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -6545,10 +6545,15 @@ void QWidget::clearFocus()
QWidget *w = this;
while (w) {
+ // Just like setFocus(), we update (clear) the focus_child of our parents
if (w->d_func()->focus_child == this)
w->d_func()->focus_child = 0;
w = w->parentWidget();
}
+ // Since focus_child is the basis for the top level QWidgetWindow's focusObject()
+ // we need to report this change to the rest of Qt, but we match setFocus() and
+ // do it at the end of the function.
+
#ifndef QT_NO_GRAPHICSVIEW
QWExtra *topData = d_func()->extra;
if (topData && topData->proxyWidget)
@@ -6569,11 +6574,15 @@ void QWidget::clearFocus()
QAccessible::updateAccessibility(&event);
#endif
}
+ }
- if (QTLWExtra *extra = window()->d_func()->maybeTopData()) {
- if (extra->window)
- emit extra->window->focusObjectChanged(extra->window->focusObject());
- }
+ // Since we've unconditionally cleared the focus_child of our parents, we need
+ // to report this to the rest of Qt. Note that the focus_child is not the same
+ // thing as the application's focusWidget, which is why this piece of code is
+ // not inside the hasFocus() block above.
+ if (QTLWExtra *extra = window()->d_func()->maybeTopData()) {
+ if (extra->window)
+ emit extra->window->focusObjectChanged(extra->window->focusObject());
}
}