aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickitem/data/multipleFocusClears.qml18
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp11
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitem/data/multipleFocusClears.qml b/tests/auto/quick/qquickitem/data/multipleFocusClears.qml
new file mode 100644
index 0000000000..f68a8901ab
--- /dev/null
+++ b/tests/auto/quick/qquickitem/data/multipleFocusClears.qml
@@ -0,0 +1,18 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 200
+ height: 200
+
+ FocusScope {
+ id: focusScope
+ anchors.fill: parent
+
+ TextInput {
+ anchors.centerIn: parent
+ text: "Some text"
+ onActiveFocusChanged: if (!activeFocus) focusScope.focus = false
+ Component.onCompleted: forceActiveFocus()
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index 7a589a48cd..9fdfa78559 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -138,6 +138,7 @@ private slots:
void scopedFocus();
void addedToCanvas();
void changeParent();
+ void multipleFocusClears();
void constructor();
void setParentItem();
@@ -675,6 +676,16 @@ void tst_qquickitem::changeParent()
}
+void tst_qquickitem::multipleFocusClears()
+{
+ //Multiple clears of focus inside a focus scope shouldn't crash. QTBUG-24714
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("multipleFocusClears.qml"));
+ view->show();
+ ensureFocus(view);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == view);
+}
+
void tst_qquickitem::constructor()
{
QQuickItem *root = new QQuickItem;