diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2021-11-04 10:41:28 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2021-12-02 16:45:42 +0100 |
commit | 3818ec46b152dce97ebe88c9b1cecde8573e0a13 (patch) | |
tree | 7c9d1b0d979a21f627133765b2428e81ac018760 | |
parent | 72e8cb6e1d5dea2f4ac16599cce9b88432e5ff18 (diff) |
Revert "Fix ListView.isCurrentItem when used with DelegateModel"
This reverts commit d9f9d773e92940786f159897623618f3bf6bcf0f.
It causes a heap-use-after-free in tst_swipeview.qml.
Task-number: QTBUG-97423
Change-Id: I42e9831ae1399a010df28c39496a7778121f5e35
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
(cherry picked from commit 5d656b31eb371c9e0bb97c558f9193b08471f1d7)
-rw-r--r-- | src/quick/items/qquickitemview.cpp | 2 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/data/qtbug86744.qml | 21 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 15 |
3 files changed, 0 insertions, 38 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index 80abd581d1..3999109e47 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -2402,8 +2402,6 @@ void QQuickItemView::createdItem(int index, QObject* object) d->repositionPackageItemAt(item, index); else if (index == d->currentIndex) d->updateCurrent(index); - } else if (index == d->currentIndex) { - d->updateCurrent(index); } } diff --git a/tests/auto/quick/qquicklistview/data/qtbug86744.qml b/tests/auto/quick/qquicklistview/data/qtbug86744.qml deleted file mode 100644 index 6dc82d57eb..0000000000 --- a/tests/auto/quick/qquicklistview/data/qtbug86744.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.15 -import QtQml.Models 2.15 - -Item { - height: 200 - width: 100 - DelegateModel { - id: dm - model: 2 - delegate: Item { - width: 100; height: 20 - property bool isCurrent: ListView.isCurrentItem - } - } - ListView { - objectName: "listView" - model: dm - currentIndex: 1 - anchors.fill: parent - } -} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index df329f8318..d3deb513d0 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -301,7 +301,6 @@ private slots: void animatedDelegate(); void dragDelegateWithMouseArea(); void dragDelegateWithMouseArea_data(); - void isCurrentItem_DelegateModel(); private: template <class T> void items(const QUrl &source); @@ -10201,20 +10200,6 @@ void tst_QQuickListView::dragDelegateWithMouseArea_data() } } -void tst_QQuickListView::isCurrentItem_DelegateModel() -{ - QScopedPointer<QQuickView> window(createView()); - window->setSource(testFileUrl("qtbug86744.qml")); - window->resize(640, 480); - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window.data())); - - QQuickListView* listView = window->rootObject()->findChild<QQuickListView*>("listView"); - QVERIFY(listView); - QVariant value = listView->itemAtIndex(1)->property("isCurrent"); - QVERIFY(value.toBool() == true); -} - QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" |