diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2024-03-21 11:20:32 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-03-28 12:40:51 +0100 |
commit | fff113b4a3259ed558e97bc66ecdacd7455dc490 (patch) | |
tree | 87dd1a378582dd1415d21e77faea44147cbd6919 /src/qml/qml | |
parent | 280a3372fd76acd662fc116f9794d2452b770fee (diff) |
QQmlListWrapper: Don't use QQmlListReference for virtualGetLength()
We cannot use QQmlListReference on detached list properties. Also, it's
wasteful.
Pick-to: 6.7
Fixes: QTBUG-118076
Change-Id: I754f19ed8c3f6eae1b3613f6866f3cf792cee8cf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmllistwrapper.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index 7102c4ee16..8d5a585b62 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -198,8 +198,9 @@ ReturnedValue QmlListWrapper::virtualGet(const Managed *m, PropertyKey id, const qint64 QmlListWrapper::virtualGetLength(const Managed *m) { Q_ASSERT(m->as<QmlListWrapper>()); - const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m); - return w->toListReference().size(); + QQmlListProperty<QObject> *property = static_cast<const QmlListWrapper *>(m)->d()->property(); + Q_ASSERT(property); + return property->count ? property->count(property) : 0; } bool QmlListWrapper::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver) |