diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-11-22 19:13:20 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-25 17:32:12 +0100 |
commit | 0d1e1ddbf5732f1755d31020f82c540f2a69f756 (patch) | |
tree | a3a878a34cf00ed3f57d9bf0bb2001c2b352ab17 /src/quick | |
parent | 70c37506e9e7c7228ca823cff0f75a5813f3bcb7 (diff) |
No assert when the focus changes and a window has no active focus item.
[ChangeLog][QtQuick] Fix crash when showing and hiding a window that has
no active focus item.
QtQuickControls hit the situation where a popup window was shown without
ever having an active focus item. When then closing the popup,
clearFocusInScope would assume it had to always modify the old focus,
but in this case the focus would be on the window itself, so there is
nothing to update.
Task-number: QTBUG-35057
Change-Id: Ifbde4689d39f98b13e6f90573cb22e28bb86f2c4
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Liang Qi <liang.qi@digia.com>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 796ddcfbe4..848eeca2a6 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -771,23 +771,24 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item, oldActiveFocusItem = activeFocusItem; newActiveFocusItem = scope; - Q_ASSERT(oldActiveFocusItem); - #ifndef QT_NO_IM qApp->inputMethod()->commit(); #endif activeFocusItem = 0; - QFocusEvent event(QEvent::FocusOut, reason); - q->sendEvent(oldActiveFocusItem, &event); - QQuickItem *afi = oldActiveFocusItem; - while (afi && afi != scope) { - if (QQuickItemPrivate::get(afi)->activeFocus) { - QQuickItemPrivate::get(afi)->activeFocus = false; - changed << afi; + if (oldActiveFocusItem) { + QFocusEvent event(QEvent::FocusOut, reason); + q->sendEvent(oldActiveFocusItem, &event); + + QQuickItem *afi = oldActiveFocusItem; + while (afi && afi != scope) { + if (QQuickItemPrivate::get(afi)->activeFocus) { + QQuickItemPrivate::get(afi)->activeFocus = false; + changed << afi; + } + afi = afi->parentItem(); } - afi = afi->parentItem(); } } |