diff options
author | Ulf Hermann <[email protected]> | 2020-03-25 15:52:10 +0100 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2020-03-27 12:29:29 +0100 |
commit | 0b2c04215dcdb0f209c46abe24c63deaaffc471c (patch) | |
tree | 5fcdf8476053ab55b30f09440190c8a228d998e0 /src/qmlmodels/qqmltableinstancemodel.cpp | |
parent | c64013079908e0d6ce90d565fbeaed7816c236ff (diff) |
QQmlTableInstanceModel: Restore draining behavior of Qt 5.14
In Qt 5.14 model items are directly deleted when draining the reusable
items pool, rather than calling deleteLater() on them. This may be
slightly more efficient and due to some unknown side effect the
deleteLater() call creates a memory leak.
Restore the direct delete in drainReusableItems().
Fixes: QTBUG-82000
Change-Id: Ia1027b1004c04e8aceaa5ff16a600849c46bf470
Reviewed-by: Fabian Kosmale <[email protected]>
Reviewed-by: Richard Moe Gustavsen <[email protected]>
Diffstat (limited to 'src/qmlmodels/qqmltableinstancemodel.cpp')
-rw-r--r-- | src/qmlmodels/qqmltableinstancemodel.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp index b0c322e633..6e21f2f389 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) |