diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-10-30 14:09:13 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-12-05 14:09:39 +0100 |
commit | db321e74413ac088edaa209a57ad5147175df041 (patch) | |
tree | cddf8d0c9c2c787e9715258ad38ad2cc8e9762a6 /tests | |
parent | cc66dd33cc44b5131c27d85daecf1b920f900f49 (diff) |
QQuickItemView: Emit correct change signal on model reset
As the variable was manually set to -1 beforehand, we would never emit
the change signal, leaving bindings stale. However, simply removing the
assignment would lead to not triggering the signal when currentIndex was
0. So now we set it to -2, which cannot happen in any other place.
Note that QTBUG-64998 was already mostly fixed due to earlier changes
fixing the currentItem part, only currentIndex was still broken
Fixes: QTBUG-68232
Fixes: QTBUG-64998
Fixes: QTBUG-63422
Change-Id: I885e06f1e258e67c3368d017bf79bff760440863
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquicklistview/data/listview-initCurrent.qml | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml index 8aff649a67..41d5bd3491 100644 --- a/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml +++ b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml @@ -7,6 +7,7 @@ Rectangle { property bool showHeader: false property bool showFooter: false property int currentItemChangedCount: 0 + property string s: ""+list.currentIndex width: 240 height: 320 diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index dac95924b5..3976dbc0f0 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -2891,7 +2891,11 @@ void tst_QQuickListView::currentIndex() // empty model should reset currentIndex to -1 QaimModel emptyModel; + window->rootObject()->setProperty("currentItemChangedCount", QVariant(0)); + QVERIFY(QQmlProperty(window->rootObject(), "s").read().toString() != QLatin1String("-1")); ctxt->setContextProperty("testModel", &emptyModel); + QCOMPARE(QQmlProperty(window->rootObject(), "s").read().toString(), "-1"); + QCOMPARE(window->rootObject()->property("currentItemChangedCount").toInt(), 1); QCOMPARE(listview->currentIndex(), -1); delete window; |