diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-12-07 19:02:39 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-25 23:55:27 +0100 |
commit | 71597472ddbe6957f47ae61b72c147846a80f16f (patch) | |
tree | 756ce46b97f0487e86c50736abe0f74dff0dc742 /src/qml/qml | |
parent | d6eaa70859fbec0f02d15bd8e8fd6ddc360ab371 (diff) |
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/ftw/qqmlrefcount_p.h | 11 | ||||
-rw-r--r-- | src/qml/qml/qqmlboundsignal.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 12 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontext.cpp | 17 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontext_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontextdata.cpp | 7 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 14 | ||||
-rw-r--r-- | src/qml/qml/qqmlguardedcontextdata_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlincubator.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlopenmetaobject.cpp | 18 | ||||
-rw-r--r-- | src/qml/qml/qqmlopenmetaobject_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 19 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertycache.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertycachecreator_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertyvalidator.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlscriptdata.cpp | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmltypecompiler.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmltypedata.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 2 |
22 files changed, 79 insertions, 66 deletions
diff --git a/src/qml/qml/ftw/qqmlrefcount_p.h b/src/qml/qml/ftw/qqmlrefcount_p.h index 06314ef5c5..cb0374d8b6 100644 --- a/src/qml/qml/ftw/qqmlrefcount_p.h +++ b/src/qml/qml/ftw/qqmlrefcount_p.h @@ -105,6 +105,17 @@ public: friend bool operator==(const QQmlRefPointer &a, const QQmlRefPointer &b) { return a.o == b.o; } friend bool operator!=(const QQmlRefPointer &a, const QQmlRefPointer &b) { return !(a == b); } + void reset(T *t = nullptr) + { + if (t == o) + return; + if (o) + o->release(); + if (t) + t->addref(); + o = t; + } + private: T *o; }; diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 2feacbd942..d71fc19e69 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -249,7 +249,7 @@ QQmlBoundSignal::QQmlBoundSignal(QObject *target, int signal, QObject *owner, QQmlEngine *engine) : QQmlNotifierEndpoint(QQmlNotifierEndpoint::QQmlBoundSignal), m_prevSignal(nullptr), m_nextSignal(nullptr), - m_enabled(true), m_expression(nullptr) + m_enabled(true) { addToObject(owner); diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 63305620b9..5b383714b4 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -316,7 +316,7 @@ void QQmlComponentPrivate::typeDataReady(QQmlTypeData *) Q_ASSERT(typeData); fromTypeData(typeData); - typeData = nullptr; + typeData.reset(); progress = 1.0; emit q->statusChanged(q->status()); @@ -335,7 +335,7 @@ void QQmlComponentPrivate::typeDataProgress(QQmlTypeData *, qreal p) void QQmlComponentPrivate::fromTypeData(const QQmlRefPointer<QQmlTypeData> &data) { url = data->finalUrl(); - compilationUnit = data->compilationUnit(); + compilationUnit.reset(data->compilationUnit()); if (!compilationUnit) { Q_ASSERT(data->isError()); @@ -357,10 +357,10 @@ void QQmlComponentPrivate::clear() { if (typeData) { typeData->unregisterCallback(this); - typeData = nullptr; + typeData.reset(); } - compilationUnit = nullptr; + compilationUnit.reset(); } QObject *QQmlComponentPrivate::doBeginCreate(QQmlComponent *q, QQmlContext *context) @@ -452,7 +452,7 @@ QQmlComponent::~QQmlComponent() if (d->typeData) { d->typeData->unregisterCallback(d); - d->typeData = nullptr; + d->typeData.reset(); } } @@ -633,7 +633,7 @@ QQmlComponent::QQmlComponent(QQmlEngine *engine, QV4::ExecutableCompilationUnit : QQmlComponent(engine, parent) { Q_D(QQmlComponent); - d->compilationUnit = compilationUnit; + d->compilationUnit.reset(compilationUnit); d->start = start; d->url = compilationUnit->finalUrl(); d->progress = 1.0; diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h index f95e83f15e..26f275f861 100644 --- a/src/qml/qml/qqmlcomponent_p.h +++ b/src/qml/qml/qqmlcomponent_p.h @@ -80,7 +80,7 @@ class Q_QML_PRIVATE_EXPORT QQmlComponentPrivate : public QObjectPrivate, public public: QQmlComponentPrivate() - : progress(0.), start(-1), engine(nullptr), creationContext(nullptr) {} + : progress(0.), start(-1), engine(nullptr) {} void loadUrl(const QUrl &newUrl, QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous); diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 69e37eb1dd..6503ac07c7 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -152,7 +152,7 @@ QT_BEGIN_NAMESPACE /*! \internal */ QQmlContext::QQmlContext(QQmlEngine *e, bool) - : QObject(*(new QQmlContextPrivate(this, nullptr, e))) + : QObject(*(new QQmlContextPrivate(this, QQmlRefPointer<QQmlContextData>(), e))) { } @@ -161,9 +161,9 @@ QQmlContext::QQmlContext(QQmlEngine *e, bool) QObject \a parent. */ QQmlContext::QQmlContext(QQmlEngine *engine, QObject *parent) - : QObject(*(new QQmlContextPrivate( - this, engine ? QQmlContextData::get(engine->rootContext()).data() : nullptr)), - parent) + : QObject(*(new QQmlContextPrivate(this, engine + ? QQmlContextData::get(engine->rootContext()) + : QQmlRefPointer<QQmlContextData>())), parent) { } @@ -172,9 +172,9 @@ QQmlContext::QQmlContext(QQmlEngine *engine, QObject *parent) QObject \a parent. */ QQmlContext::QQmlContext(QQmlContext *parentContext, QObject *parent) - : QObject(*(new QQmlContextPrivate( - this, parentContext ? QQmlContextData::get(parentContext).data() : nullptr)), - parent) + : QObject(*(new QQmlContextPrivate(this, parentContext + ? QQmlContextData::get(parentContext) + : QQmlRefPointer<QQmlContextData>())), parent) { } @@ -555,7 +555,8 @@ void QQmlContextPrivate::emitDestruction() // deref'd. It's OK to pass a half-created publicContext here. We will not dereference it during // construction. QQmlContextPrivate::QQmlContextPrivate( - QQmlContext *publicContext, QQmlContextData *parent, QQmlEngine *engine) : + QQmlContext *publicContext, const QQmlRefPointer<QQmlContextData> &parent, + QQmlEngine *engine) : m_data(new QQmlContextData(QQmlContextData::OwnedByPublicContext, publicContext, parent, engine)) { diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index 1c2cb7ff67..b7259afb5d 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -105,7 +105,7 @@ private: friend class QQmlContextData; QQmlContextPrivate(QQmlContextData *data) : m_data(data) {} - QQmlContextPrivate(QQmlContext *publicContext, QQmlContextData *parent, + QQmlContextPrivate(QQmlContext *publicContext, const QQmlRefPointer<QQmlContextData> &parent, QQmlEngine *engine = nullptr); // Intentionally a bare pointer. QQmlContextData knows whether it owns QQmlContext or vice diff --git a/src/qml/qml/qqmlcontextdata.cpp b/src/qml/qml/qqmlcontextdata.cpp index 8a95c7c3f1..c5df906bf7 100644 --- a/src/qml/qml/qqmlcontextdata.cpp +++ b/src/qml/qml/qqmlcontextdata.cpp @@ -61,7 +61,7 @@ void QQmlContextData::installContext(QQmlData *ddata, QQmlContextData::QmlObject } else { ddata->context = this; } - ddata->ownContext = ddata->context; + ddata->ownContext.reset(ddata->context); } else if (!ddata->context) { ddata->context = this; } @@ -175,7 +175,7 @@ QQmlContextData::~QQmlContextData() addref(); if (m_engine) invalidate(); - m_linkedContext = nullptr; + m_linkedContext.reset(); Q_ASSERT(refCount() == 1); clearContext(); @@ -195,8 +195,9 @@ QQmlContextData::~QQmlContextData() QQmlGuardedContextData *contextGuard = m_contextGuards; while (contextGuard) { + // TODO: Is this dead code? Why? QQmlGuardedContextData *next = contextGuard->next(); - contextGuard->reset(); + contextGuard->setContextData({}); contextGuard = next; } m_contextGuards = nullptr; diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 6f550ec725..a88cea55cd 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -256,7 +256,7 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) { if (QQmlData *d = QQmlData::get(o)) { if (d->ownContext) { - for (QQmlRefPointer<QQmlContextData> lc = d->ownContext->linkedContext().data(); lc; + for (QQmlRefPointer<QQmlContextData> lc = d->ownContext->linkedContext(); lc; lc = lc->linkedContext()) { lc->invalidate(); if (lc->contextObject() == o) @@ -265,7 +265,7 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) d->ownContext->invalidate(); if (d->ownContext->contextObject() == o) d->ownContext->setContextObject(nullptr); - d->ownContext = nullptr; + d->ownContext.reset(); d->context = nullptr; } @@ -285,7 +285,7 @@ QQmlData::QQmlData() bindingBitsArraySize(InlineBindingArraySize), notifyList(nullptr), bindings(nullptr), signalHandlers(nullptr), nextContextObject(nullptr), prevContextObject(nullptr), lineNumber(0), columnNumber(0), jsEngineId(0), - propertyCache(nullptr), guards(nullptr), extendedData(nullptr) + guards(nullptr), extendedData(nullptr) { memset(bindingBitsValue, 0, sizeof(bindingBitsValue)); init(); @@ -426,7 +426,7 @@ void QQmlData::setQueuedForDeletion(QObject *object) ddata->context->emitDestruction(); if (ddata->ownContext->contextObject() == object) ddata->ownContext->setContextObject(nullptr); - ddata->ownContext = nullptr; + ddata->ownContext.reset(); ddata->context = nullptr; } ddata->isQueuedForDeletion = true; @@ -1258,7 +1258,7 @@ void QQmlData::destroyed(QObject *object) if (bindings && !bindings->ref.deref()) delete bindings; - compilationUnit = nullptr; + compilationUnit.reset(); qDeleteAll(deferredData); deferredData.clear(); @@ -1305,9 +1305,9 @@ void QQmlData::destroyed(QObject *object) free(bindingBits); if (propertyCache) - propertyCache = nullptr; + propertyCache.reset(); - ownContext = nullptr; + ownContext.reset(); while (guards) { QQmlGuard<QObject> *guard = static_cast<QQmlGuard<QObject> *>(guards); diff --git a/src/qml/qml/qqmlguardedcontextdata_p.h b/src/qml/qml/qqmlguardedcontextdata_p.h index d1bd1d5cf4..78d880431d 100644 --- a/src/qml/qml/qqmlguardedcontextdata_p.h +++ b/src/qml/qml/qqmlguardedcontextdata_p.h @@ -103,14 +103,14 @@ public: QQmlGuardedContextData *next() const { return m_next; } +private: void reset() { - m_contextData = nullptr; + m_contextData.reset(); m_next = nullptr; m_prev = nullptr; } -private: void unlink() { if (m_prev) { diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index 33b04eba14..5a3fd2a1f4 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -140,7 +140,7 @@ QQmlIncubatorPrivate::~QQmlIncubatorPrivate() void QQmlIncubatorPrivate::clear() { - compilationUnit = nullptr; + compilationUnit.reset(); if (next.isInList()) { next.remove(); enginePriv->incubatorCount--; @@ -152,7 +152,7 @@ void QQmlIncubatorPrivate::clear() if (!rootContext.isNull()) { if (rootContext->incubator()) rootContext->setIncubator(nullptr); - rootContext = nullptr; + rootContext.setContextData({}); } if (nextWaitingFor.isInList()) { diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 732ab0e9f3..547894b897 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -536,7 +536,7 @@ void QQmlJavaScriptExpression::setupFunction(QV4::ExecutionContext *qmlContext, return; m_qmlScope.set(qmlContext->engine(), *qmlContext); m_v4Function = f; - setCompilationUnit(m_v4Function->executableCompilationUnit()); + m_compilationUnit.reset(m_v4Function->executableCompilationUnit()); } void QQmlJavaScriptExpression::setCompilationUnit(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit) diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 388ab89fa8..ce14f87ec5 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -92,7 +92,7 @@ QQmlObjectCreator::QQmlObjectCreator( sharedState->allCreatedObjects.allocate(compilationUnit->totalObjectCount()); sharedState->allJavaScriptObjects = nullptr; sharedState->creationContext = creationContext; - sharedState->rootContext = nullptr; + sharedState->rootContext.reset(); sharedState->hadRequiredProperties = false; if (auto profiler = QQmlEnginePrivate::get(engine)->profiler) { @@ -127,7 +127,6 @@ void QQmlObjectCreator::init(QQmlRefPointer<QQmlContextData> providedParentConte compilationUnit->linkToEngine(v4); qmlUnit = compilationUnit->unitData(); - context = nullptr; _qobject = nullptr; _scopeObject = nullptr; _bindingTarget = nullptr; @@ -135,7 +134,6 @@ void QQmlObjectCreator::init(QQmlRefPointer<QQmlContextData> providedParentConte _compiledObject = nullptr; _compiledObjectIndex = -1; _ddata = nullptr; - _propertyCache = nullptr; _vmeMetaObject = nullptr; _qmlContext = nullptr; } @@ -1307,7 +1305,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo bindings << binding; } } - customParser->applyBindings(instance, compilationUnit.data(), bindings); + customParser->applyBindings(instance, compilationUnit, bindings); customParser->engine = nullptr; customParser->imports = (QQmlTypeNameCache*)nullptr; @@ -1661,7 +1659,7 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject * if (!target) continue; QQmlData *targetDData = QQmlData::get(target, /*create*/false); - if (targetDData == nullptr || targetDData->propertyCache == nullptr) + if (targetDData == nullptr || targetDData->propertyCache.isNull()) continue; int coreIndex = QQmlPropertyIndex::fromEncoded(alias->encodedMetaPropertyIndex).coreIndex(); QQmlPropertyData *const targetProperty = targetDData->propertyCache->property(coreIndex); diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp index 8b0e0c66d5..ae227109bb 100644 --- a/src/qml/qml/qqmlopenmetaobject.cpp +++ b/src/qml/qml/qqmlopenmetaobject.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE class QQmlOpenMetaObjectTypePrivate { public: - QQmlOpenMetaObjectTypePrivate() : mem(nullptr), cache(nullptr) {} + QQmlOpenMetaObjectTypePrivate() : mem(nullptr) {} void init(const QMetaObject *metaObj); @@ -58,7 +58,7 @@ public: QHash<QByteArray, int> names; QMetaObjectBuilder mob; QMetaObject *mem; - QQmlPropertyCache *cache; + QQmlRefPointer<QQmlPropertyCache> cache; QSet<QQmlOpenMetaObject*> referers; }; @@ -72,8 +72,6 @@ QQmlOpenMetaObjectType::~QQmlOpenMetaObjectType() { if (d->mem) free(d->mem); - if (d->cache) - d->cache->release(); delete d; } @@ -225,7 +223,7 @@ public: void dropPropertyCache() { if (QQmlData *ddata = QQmlData::get(object, /*create*/false)) - ddata->propertyCache = nullptr; + ddata->propertyCache.reset(); } QQmlOpenMetaObject *q; @@ -250,7 +248,8 @@ QQmlOpenMetaObject::QQmlOpenMetaObject(QObject *obj, const QMetaObject *base) op->metaObject = this; } -QQmlOpenMetaObject::QQmlOpenMetaObject(QObject *obj, QQmlOpenMetaObjectType *type) +QQmlOpenMetaObject::QQmlOpenMetaObject( + QObject *obj, const QQmlRefPointer<QQmlOpenMetaObjectType> &type) : d(new QQmlOpenMetaObjectPrivate(this, obj)) { d->type = type; @@ -424,12 +423,11 @@ void QQmlOpenMetaObject::setCached(bool c) QQmlData *qmldata = QQmlData::get(d->object, true); if (d->cacheProperties) { if (!d->type->d->cache) - d->type->d->cache = new QQmlPropertyCache(this); + d->type->d->cache.adopt(new QQmlPropertyCache(this)); qmldata->propertyCache = d->type->d->cache; } else { - if (d->type->d->cache) - d->type->d->cache->release(); - qmldata->propertyCache = nullptr; + d->type->d->cache.reset(); + qmldata->propertyCache.reset(); } } diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h index e455725bdf..57d8d01514 100644 --- a/src/qml/qml/qqmlopenmetaobject_p.h +++ b/src/qml/qml/qqmlopenmetaobject_p.h @@ -93,7 +93,7 @@ class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObject : public QAbstractDynamicMetaObjec { public: QQmlOpenMetaObject(QObject *, const QMetaObject * = nullptr); - QQmlOpenMetaObject(QObject *, QQmlOpenMetaObjectType *); + QQmlOpenMetaObject(QObject *, const QQmlRefPointer<QQmlOpenMetaObjectType> &); ~QQmlOpenMetaObject() override; QVariant value(const QByteArray &) const; diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 5753a2cb33..31cc9374b4 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -152,8 +152,10 @@ QQmlProperty::QQmlProperty(QObject *obj) QQmlProperty::QQmlProperty(QObject *obj, QQmlContext *ctxt) : d(new QQmlPropertyPrivate) { - d->context = ctxt?QQmlContextData::get(ctxt):nullptr; - d->engine = ctxt?ctxt->engine():nullptr; + if (ctxt) { + d->context = QQmlContextData::get(ctxt); + d->engine = ctxt->engine(); + } d->initDefault(obj); } @@ -204,12 +206,15 @@ QQmlProperty::QQmlProperty(QObject *obj, const QString &name) QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlContext *ctxt) : d(new QQmlPropertyPrivate) { - d->context = ctxt?QQmlContextData::get(ctxt):nullptr; - d->engine = ctxt?ctxt->engine():nullptr; + if (ctxt) { + d->context = QQmlContextData::get(ctxt); + d->engine = ctxt->engine(); + } + d->initProperty(obj, name); if (!isValid()) { d->object = nullptr; - d->context = nullptr; + d->context.reset(); d->engine = nullptr; } } @@ -226,7 +231,7 @@ QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlEngine *engine d->initProperty(obj, name); if (!isValid()) { d->object = nullptr; - d->context = nullptr; + d->context.reset(); d->engine = nullptr; } } @@ -243,7 +248,7 @@ QQmlProperty QQmlPropertyPrivate::create(QObject *target, const QString &propert d->initProperty(target, propertyName, flags); if (!result.isValid()) { d->object = nullptr; - d->context = nullptr; + d->context.reset(); d->engine = nullptr; } return result; 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> QQmlPropertyCache::copy(int reserve) { QQmlRefPointer<QQmlPropertyCache> cache = QQmlRefPointer<QQmlPropertyCache>( new QQmlPropertyCache(), QQmlRefPointer<QQmlPropertyCache>::Adopt); - cache->_parent = this; + cache->_parent.reset(this); cache->propertyIndexCacheStart = propertyIndexCache.count() + propertyIndexCacheStart; cache->methodIndexCacheStart = methodIndexCache.count() + methodIndexCacheStart; cache->signalHandlerIndexCacheStart = signalHandlerIndexCache.count() + signalHandlerIndexCacheStart; diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index b29ab44a23..e74e91c638 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -245,7 +245,7 @@ QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectsIncrementally() if (nodeIt != nodesSorted.rend()) { const auto &ic = allICs[nodeIt->index]; QV4::ResolvedTypeReference *typeRef = objectContainer->resolvedType(ic.nameIndex); - Q_ASSERT(propertyCaches->at(ic.objectIndex) == nullptr); + Q_ASSERT(propertyCaches->at(ic.objectIndex).isNull()); Q_ASSERT(typeRef->typePropertyCache().isNull()); // not set yet QByteArray icTypeName { objectContainer->stringAt(ic.nameIndex).toUtf8() }; @@ -461,7 +461,7 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int newClassName = typeClassName; } if (newClassName.isEmpty()) { - newClassName = QQmlMetaObject(baseTypeCache.data()).className(); + newClassName = QQmlMetaObject(baseTypeCache).className(); newClassName.append("_QML_"); newClassName.append(QByteArray::number(classIndexCounter.fetchAndAddRelaxed(1))); } diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp index c91739c138..936f35190c 100644 --- a/src/qml/qml/qqmlpropertyvalidator.cpp +++ b/src/qml/qml/qqmlpropertyvalidator.cpp @@ -793,7 +793,7 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *propert QQmlRefPointer<QQmlPropertyCache> c = propertyCaches.at(binding->value.objectIndex); while (c && !isAssignable) { isAssignable |= c == propertyMetaObject; - c = c->parent().data(); + c = c->parent(); } if (!isAssignable) { diff --git a/src/qml/qml/qqmlscriptdata.cpp b/src/qml/qml/qqmlscriptdata.cpp index 684564fcfb..c2e8c8e9d5 100644 --- a/src/qml/qml/qqmlscriptdata.cpp +++ b/src/qml/qml/qqmlscriptdata.cpp @@ -50,8 +50,7 @@ QT_BEGIN_NAMESPACE QQmlScriptData::QQmlScriptData() - : typeNameCache(nullptr) - , m_loaded(false) + : m_loaded(false) { } @@ -100,7 +99,7 @@ QQmlRefPointer<QQmlContextData> QQmlScriptData::qmlContextDataForContext( } QV4::ScopedValue v(scope); for (int ii = 0; ii < scripts.count(); ++ii) { - v = scripts.at(ii)->scriptData()->scriptValueForContext(qmlContextData.data()); + v = scripts.at(ii)->scriptData()->scriptValueForContext(qmlContextData); scriptsArray->put(ii, v); } diff --git a/src/qml/qml/qqmltypecompiler.cpp b/src/qml/qml/qqmltypecompiler.cpp index f54a63e9d2..a4ad9d2327 100644 --- a/src/qml/qml/qqmltypecompiler.cpp +++ b/src/qml/qml/qqmltypecompiler.cpp @@ -351,7 +351,7 @@ bool SignalHandlerResolver::resolveSignalHandlerExpressions( if (!attachedType) COMPILE_EXCEPTION(binding, tr("Non-existent attached object")); QQmlRefPointer<QQmlPropertyCache> cache = QQmlMetaType::propertyCache(attachedType); - if (!resolveSignalHandlerExpressions(attachedObj, bindingPropertyName, cache.data())) + if (!resolveSignalHandlerExpressions(attachedObj, bindingPropertyName, cache)) return false; continue; } diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index 38ae0ed7e5..aa3be1cabf 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -314,7 +314,7 @@ void QQmlTypeData::done() const auto encounteredErrors = errors(); for (const QQmlError &e : encounteredErrors) qCDebug(DBG_DISK_CACHE) << e.toString(); - m_compiledData = nullptr; + m_compiledData.reset(); } }); @@ -432,7 +432,7 @@ void QQmlTypeData::done() if (!loadFromSource()) return; m_backupSourceCode = SourceCodeData(); - m_compiledData = nullptr; + m_compiledData.reset(); } if (!m_document.isNull()) { diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index d0d5e18cf1..a1ca2fd3d4 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1466,7 +1466,7 @@ void QQmlXMLHttpRequest::finished() dispatchCallbackSafely(); m_thisObject.clear(); - m_qmlContext = nullptr; + m_qmlContext.reset(); } |