diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-02-22 13:03:40 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-02-23 13:47:26 +0000 |
commit | ec4c897ddab774b6ce873370bdc202f0bc7e76a3 (patch) | |
tree | b14e21d282be60e04c221756ee4cb4ef4cf852b3 /tests | |
parent | b6d1e97be274e67a47cce950ed4cf05518eebcc8 (diff) |
Fix ListModel.get(idx) == ListModel.get(idx)
This is a regression introduced with commit
4876ea6a18ccdfd72014582aa5d50ab9f6b6ec9e. Where we previously always
returned the same JS object, we would afterwards return a new JS object
for every invocation, which breaks reference comparison. As we store the
JS wrapper for the list element in the QQmlData->jsWrapper we can avoid
repeated allocations. In order for that wrapper to keep working after
modifications (insertion, etc.) to the list model, we have to replace
the static element index with a reference to the node model meta-object,
which also has an element index that however is kept up-to-date by the
list model itself.
Change-Id: I4368de6b6d86687fe96fbf73bd60b80b69d7b058
Task-number: QTBUG-52017
Reviewed-by: Michael Brasser <michael.brasser@live.com>
(cherry picked from commit 44a89492b49f23a975377795dbb7a48916cb5081)
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 653e7543c0..45cf8ea39e 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -449,6 +449,7 @@ void tst_qqmllistmodel::dynamic_data() QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << "" << dr; QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << "" << dr; QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << "" << dr; + QTest::newRow("get5") << "{append({'foo':123});get(0) == get(0)}" << 1 << "" << dr; QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << "" << dr; QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << "" << dr; |