From 71597472ddbe6957f47ae61b72c147846a80f16f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 7 Dec 2021 19:02:39 +0100 Subject: Avoid ping-pong between plain pointers and QQmlRefPointer We want to deal in QQmlRefPointer as much as possible. In particular, assigning nullptr to a QQmlRefPointer triggers the creation of an empty QQmlRefPointer and the assignment of that one. Provide a reset() method to do this in a cleaner way. In turn, make QQmlGuardedContextData::reset() private. It's really dangerous and should not be called from outside. setContextData() is safer but may do additional work. The only place from where reset() was previously called in its public capacity is probably dead code, though. Change-Id: Idb72e255dbfad6e5dd963dc76d719bb9edc10471 Reviewed-by: Fabian Kosmale --- src/qml/qml/qqmlpropertycache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/qml/qqmlpropertycache.cpp') diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index cc5d9e11ac..66e83c1655 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -187,7 +187,7 @@ QQmlRefPointer QQmlPropertyCache::copy(int reserve) { QQmlRefPointer cache = QQmlRefPointer( new QQmlPropertyCache(), QQmlRefPointer::Adopt); - cache->_parent = this; + cache->_parent.reset(this); cache->propertyIndexCacheStart = propertyIndexCache.count() + propertyIndexCacheStart; cache->methodIndexCacheStart = methodIndexCache.count() + methodIndexCacheStart; cache->signalHandlerIndexCacheStart = signalHandlerIndexCache.count() + signalHandlerIndexCacheStart; -- cgit v1.2.3