diff options
author | Caroline Chao <caroline.chao@digia.com> | 2013-03-19 14:01:54 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-19 19:44:10 +0100 |
commit | 9b25a6f39ee59fe1bb4352a5f2e4ef4a91f1f2c3 (patch) | |
tree | c20b30ae5486a4105b0f2f22bf4fd4c6ce84f3f3 /tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | |
parent | ea8b11259ad68a8ff44708786ecf54e5a8a272d8 (diff) |
QQuickItemView: Add guard before returning currentItem item
And don't check if the currentItem is empty before calling
applyPendingChanges().
And an autotest. (Patch from Steffen Imhof)
Task-number: QTBUG-30227
Change-Id: Ia16362a6d0dce771f20772929c32e9306ed0e0f9
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests/auto/quick/qquicklistview/tst_qquicklistview.cpp')
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index c034fe83c8..3b4a41e203 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -207,6 +207,7 @@ private slots: void parentBinding(); void defaultHighlightMoveDuration(); + void accessEmptyCurrentItem_QTBUG_30227(); private: template <class T> void items(const QUrl &source, bool forceLayout); @@ -6814,6 +6815,21 @@ void tst_QQuickListView::defaultHighlightMoveDuration() QCOMPARE(obj->property("highlightMoveDuration").toInt(), -1); } +void tst_QQuickListView::accessEmptyCurrentItem_QTBUG_30227() +{ + QQuickView *window = createView(); + window->setSource(testFileUrl("emptymodel.qml")); + + QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>(); + QTRY_VERIFY(listview != 0); + + QMetaObject::invokeMethod(window->rootObject(), "remove"); + QVERIFY(window->rootObject()->property("isCurrentItemNull").toBool()); + + QMetaObject::invokeMethod(window->rootObject(), "add"); + QVERIFY(!window->rootObject()->property("isCurrentItemNull").toBool()); +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" |