diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-03-26 01:00:11 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-04-09 10:08:41 +0200 |
commit | 2812184e1bb87cd94d2989162bc6ea954bb585c4 (patch) | |
tree | 25460548730e2ddc1f6f328d54e97d3fbfb49d21 /src/qmlmodels | |
parent | cd4a99a7ba92968bf88da9af2624bb738d71e726 (diff) | |
parent | bf205b45a29ba80d94df3b6bac5fec4c7cd79bf9 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
src/qml/jsruntime/qv4executablecompilationunit.cpp
src/qml/jsruntime/qv4executablecompilationunit_p.h
src/qml/qml/qqmlobjectcreator.cpp
src/qml/qml/qqmlpropertycachecreator_p.h
src/qml/qml/qqmltypecompiler.cpp
src/qml/qml/qqmltypedata.cpp
tests/auto/qml/qmlformat/tst_qmlformat.cpp
tools/qmllint/scopetree.cpp
src/qml/qml/qqmlapplicationengine_p.h
Adjusted tools/qmllint/findunqualified.cpp to use newer API
Change-Id: Ibfb4678ca39d626d47527265e3c96e43313873d4
Diffstat (limited to 'src/qmlmodels')
-rw-r--r-- | src/qmlmodels/qqmldelegatemodel.cpp | 18 | ||||
-rw-r--r-- | src/qmlmodels/qqmldelegatemodel_p_p.h | 1 | ||||
-rw-r--r-- | src/qmlmodels/qqmltableinstancemodel.cpp | 13 | ||||
-rw-r--r-- | src/qmlmodels/qqmltableinstancemodel_p.h | 7 |
4 files changed, 23 insertions, 16 deletions
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp index 646ac5e9f9..c94493dee8 100644 --- a/src/qmlmodels/qqmldelegatemodel.cpp +++ b/src/qmlmodels/qqmldelegatemodel.cpp @@ -926,17 +926,11 @@ void PropertyUpdater::doUpdate() auto mo = sender->metaObject(); auto signalIndex = QObject::senderSignalIndex(); ++updateCount; - // start at 0 instead of propertyOffset to handle properties from parent hierarchy - for (auto i = 0; i < mo->propertyCount() + mo->propertyOffset(); ++i) { - auto property = mo->property(i); - if (property.notifySignal().methodIndex() == signalIndex) { - // we synchronize between required properties and model rolenames by name - // that's why the QQmlProperty and the metaobject property must have the same name - QQmlProperty qmlProp(parent(), QString::fromLatin1(property.name())); - qmlProp.write(property.read(QObject::sender())); - return; - } - } + auto property = mo->property(changeSignalIndexToPropertyIndex[signalIndex]); + // we synchronize between required properties and model rolenames by name + // that's why the QQmlProperty and the metaobject property must have the same name + QQmlProperty qmlProp(parent(), QString::fromLatin1(property.name())); + qmlProp.write(property.read(QObject::sender())); } void PropertyUpdater::breakBinding() @@ -1014,8 +1008,10 @@ void QQDMIncubationTask::initializeRequiredProperties(QQmlDelegateModelItem *mod QMetaMethod changeSignal = prop.notifySignal(); static QMetaMethod updateSlot = PropertyUpdater::staticMetaObject.method( PropertyUpdater::staticMetaObject.indexOfSlot("doUpdate()")); + QMetaObject::Connection conn = QObject::connect(itemOrProxy, changeSignal, updater, updateSlot); + updater->changeSignalIndexToPropertyIndex[changeSignal.methodIndex()] = i; auto propIdx = object->metaObject()->indexOfProperty(propName.toUtf8()); QMetaMethod writeToPropSignal = object->metaObject()->property(propIdx).notifySignal(); diff --git a/src/qmlmodels/qqmldelegatemodel_p_p.h b/src/qmlmodels/qqmldelegatemodel_p_p.h index 20fb47f021..491e8025b8 100644 --- a/src/qmlmodels/qqmldelegatemodel_p_p.h +++ b/src/qmlmodels/qqmldelegatemodel_p_p.h @@ -475,6 +475,7 @@ class PropertyUpdater : public QObject public: PropertyUpdater(QObject *parent); QHash<int, QMetaObject::Connection> senderToConnection; + QHash<int, int> changeSignalIndexToPropertyIndex; int updateCount = 0; public Q_SLOTS: void doUpdate(); diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp index 4152cbe3ea..332a5447b1 100644 --- a/src/qmlmodels/qqmltableinstancemodel.cpp +++ b/src/qmlmodels/qqmltableinstancemodel.cpp @@ -232,14 +232,17 @@ QQmlInstanceModel::ReleaseFlags QQmlTableInstanceModel::release(QObject *object, } // The item is not reused or referenced by anyone, so just delete it - destroyModelItem(modelItem); + destroyModelItem(modelItem, Deferred); return QQmlInstanceModel::Destroyed; } -void QQmlTableInstanceModel::destroyModelItem(QQmlDelegateModelItem *modelItem) +void QQmlTableInstanceModel::destroyModelItem(QQmlDelegateModelItem *modelItem, DestructionMode mode) { emit destroyingItem(modelItem->object); - modelItem->destroyObject(); + if (mode == Deferred) + modelItem->destroyObject(); + else + delete modelItem->object; delete modelItem; } @@ -284,7 +287,9 @@ void QQmlTableInstanceModel::cancel(int index) void QQmlTableInstanceModel::drainReusableItemsPool(int maxPoolTime) { - m_reusableItemsPool.drain(maxPoolTime, [=](QQmlDelegateModelItem *modelItem){ destroyModelItem(modelItem); }); + m_reusableItemsPool.drain(maxPoolTime, [this](QQmlDelegateModelItem *modelItem) { + destroyModelItem(modelItem, Immediate); + }); } void QQmlTableInstanceModel::reuseItem(QQmlDelegateModelItem *item, int newModelIndex) diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h index 57b9b26e43..defe513ef9 100644 --- a/src/qmlmodels/qqmltableinstancemodel_p.h +++ b/src/qmlmodels/qqmltableinstancemodel_p.h @@ -124,6 +124,11 @@ public: int indexOf(QObject *, QObject *) const override { Q_UNREACHABLE(); return 0; } private: + enum DestructionMode { + Deferred, + Immediate + }; + QQmlComponent *resolveDelegate(int index); QQmlAdaptorModel m_adaptorModel; @@ -141,7 +146,7 @@ private: void deleteIncubationTaskLater(QQmlIncubator *incubationTask); void deleteAllFinishedIncubationTasks(); QQmlDelegateModelItem *resolveModelItem(int index); - void destroyModelItem(QQmlDelegateModelItem *modelItem); + void destroyModelItem(QQmlDelegateModelItem *modelItem, DestructionMode mode); void dataChangedCallback(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles); |