aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickitem
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den.exter@jollamobile.com>2013-11-21 11:10:10 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-22 02:01:39 +0100
commit1a76a4926a7cfecbe2bf4d75589af54e98c201c5 (patch)
treeafa2e9f9654bc9e5ce016c2167d4765d1a8bcac7 /tests/auto/quick/qquickitem
parent9b7dabbe9a347be95ed5206a4e4ab5218bbdb2a6 (diff)
Fix assert after giving focus to a disabled item.
If an item has focus stolen by another item remove activeFocus from it even if the item that gains focus doesn't gain activeFocus. Otherwise the focus tree will enter a state where an item that is not the subFocusItem of its focus scope has activeFocus which is invalid and will trigger an assert in QQuickWindowPrivate::clearFocusInScope(). Task-number: QTBUG-34779 Change-Id: I72408ec0e4fd9b05ef595147ef1ef95b6aed1c16 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests/auto/quick/qquickitem')
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index 97e002361b..2c6dcd72ba 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -44,7 +44,6 @@
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickwindow.h>
#include <QtQuick/qquickview.h>
-#include <QtWidgets/QGraphicsSceneMouseEvent>
#include "private/qquickfocusscope_p.h"
#include "private/qquickitem_p.h"
#include <qpa/qwindowsysteminterface.h>
@@ -1151,6 +1150,30 @@ void tst_qquickitem::enabledFocus()
QCOMPARE(child2.hasFocus(), false);
QCOMPARE(child2.hasActiveFocus(), false);
QCOMPARE(window.activeFocusItem(), static_cast<QQuickItem *>(&child1));
+
+ child2.setFocus(true);
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(window.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ root.setEnabled(false);
+ QCOMPARE(root.isEnabled(), false);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), false);
+ QCOMPARE(child1.isEnabled(), false);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(window.activeFocusItem(), window.contentItem());
}
static inline QByteArray msgItem(const QQuickItem *item)