aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-07-02 16:37:05 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-07-02 17:53:58 +0200
commit6dffa5400fd056e3862a2f8905362679c1bb6be7 (patch)
tree10055a6b7ac79b41a5a6dda8bac5e99e4fd6777b
parent29c61f83c98c269c1c862a668c0a91a1027ee2d2 (diff)
QQmlDelegateModel: ref objects before allocating
The allocation might run the garbage collector and that might delete the object before we ref it. Change-Id: I13cb74ab011a4eabc8df136023958791a2183df0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 63bc64d5e6..af328fbe2a 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -2656,10 +2656,10 @@ QQmlV4Handle QQmlDelegateModelGroup::get(int index)
model->m_cacheMetaType->initializePrototype();
QV4::ExecutionEngine *v4 = model->m_cacheMetaType->v4Engine;
QV4::Scope scope(v4);
+ ++cacheItem->scriptRef;
QV4::ScopedObject o(scope, v4->memoryManager->allocate<QQmlDelegateModelItemObject>(cacheItem));
QV4::ScopedObject p(scope, model->m_cacheMetaType->modelItemProto.value());
o->setPrototypeOf(p);
- ++cacheItem->scriptRef;
return QQmlV4Handle(o);
}