diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-03-10 12:09:00 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-03-14 16:44:35 +0100 |
commit | 9de2b11a7033a1969156277bafa848b5c178baa1 (patch) | |
tree | e9d349e5165350b50065663e3b9efadd94738cb8 /src/qml/jsruntime | |
parent | e5246cafffb93f69a49c133210390c253fcb71f2 (diff) |
Make most QQmlPropertyData const
You really should not mess with that after creating the property cache.
Change-Id: I070200772475bb67f539dbbd85a298020b14ca79
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4executablecompilationunit_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4lookup_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qmlcontext.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 24 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper_p.h | 13 |
5 files changed, 24 insertions, 25 deletions
diff --git a/src/qml/jsruntime/qv4executablecompilationunit_p.h b/src/qml/jsruntime/qv4executablecompilationunit_p.h index 5c73b40121..673a181eec 100644 --- a/src/qml/jsruntime/qv4executablecompilationunit_p.h +++ b/src/qml/jsruntime/qv4executablecompilationunit_p.h @@ -89,7 +89,7 @@ struct InlineComponentData { namespace QV4 { // index is per-object binding index -typedef QVector<QQmlPropertyData*> BindingPropertyData; +typedef QVector<const QQmlPropertyData *> BindingPropertyData; class CompilationUnitMapper; class ResolvedTypeReference; diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h index 7e5c15ba13..09e8c4e2d2 100644 --- a/src/qml/jsruntime/qv4lookup_p.h +++ b/src/qml/jsruntime/qv4lookup_p.h @@ -253,7 +253,7 @@ Q_STATIC_ASSERT(std::is_standard_layout<Lookup>::value); Q_STATIC_ASSERT(offsetof(Lookup, getter) == 0); inline void setupQObjectLookup( - Lookup *lookup, const QQmlData *ddata, QQmlPropertyData *propertyData) + Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData) { lookup->releasePropertyCache(); Q_ASSERT(!ddata->propertyCache.isNull()); @@ -263,7 +263,7 @@ inline void setupQObjectLookup( } inline void setupQObjectLookup( - Lookup *lookup, const QQmlData *ddata, QQmlPropertyData *propertyData, + Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData, const Object *self) { lookup->qobjectLookup.ic = self->internalClass(); @@ -272,7 +272,7 @@ inline void setupQObjectLookup( inline void setupQObjectLookup( - Lookup *lookup, const QQmlData *ddata, QQmlPropertyData *propertyData, + Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData, const Object *self, const Object *qmlType) { lookup->qobjectLookup.qmlTypeIc = qmlType->internalClass(); diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index f7a5f897c8..2bd06752e1 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -296,7 +296,7 @@ ReturnedValue QQmlContextWrapper::getPropertyAndBase(const QQmlContextWrapper *r if (scopeObject) { bool hasProp = false; - QQmlPropertyData *propertyData = nullptr; + const QQmlPropertyData *propertyData = nullptr; QV4::ScopedValue result(scope, QV4::QObjectWrapper::getQmlProperty(v4, context, scopeObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp, &propertyData)); if (hasProp) { @@ -323,7 +323,7 @@ ReturnedValue QQmlContextWrapper::getPropertyAndBase(const QQmlContextWrapper *r // Search context object if (QObject *contextObject = context->contextObject()) { bool hasProp = false; - QQmlPropertyData *propertyData = nullptr; + const QQmlPropertyData *propertyData = nullptr; result = QV4::QObjectWrapper::getQmlProperty(v4, context, contextObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp, &propertyData); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 596d65b47f..5d29cab79b 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -233,21 +233,21 @@ void QObjectWrapper::initializeBindings(ExecutionEngine *engine) engine->functionPrototype()->defineDefaultProperty(QStringLiteral("disconnect"), method_disconnect); } -QQmlPropertyData *QObjectWrapper::findProperty( +const QQmlPropertyData *QObjectWrapper::findProperty( const QQmlRefPointer<QQmlContextData> &qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const { return findProperty(d()->object(), qmlContext, name, revisionMode, local); } -QQmlPropertyData *QObjectWrapper::findProperty( +const QQmlPropertyData *QObjectWrapper::findProperty( QObject *o, const QQmlRefPointer<QQmlContextData> &qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) { Q_UNUSED(revisionMode); QQmlData *ddata = QQmlData::get(o, false); - QQmlPropertyData *result = nullptr; + const QQmlPropertyData *result = nullptr; if (ddata && ddata->propertyCache) result = ddata->propertyCache->property(name, o, qmlContext); else @@ -357,7 +357,7 @@ ReturnedValue QObjectWrapper::getQmlProperty( return *methodValue; QQmlPropertyData local; - QQmlPropertyData *result = findProperty(qmlContext, name, revisionMode, &local); + const QQmlPropertyData *result = findProperty(qmlContext, name, revisionMode, &local); if (!result) { // Check for attached properties @@ -387,7 +387,7 @@ ReturnedValue QObjectWrapper::getQmlProperty( ReturnedValue QObjectWrapper::getQmlProperty( ExecutionEngine *engine, const QQmlRefPointer<QQmlContextData> &qmlContext, QObject *object, String *name, QObjectWrapper::RevisionMode revisionMode, bool *hasProperty, - QQmlPropertyData **property) + const QQmlPropertyData **property) { if (QQmlData::wasDeleted(object)) { if (hasProperty) @@ -400,7 +400,7 @@ ReturnedValue QObjectWrapper::getQmlProperty( QQmlData *ddata = QQmlData::get(object, false); QQmlPropertyData local; - QQmlPropertyData *result = findProperty(object, qmlContext, name, revisionMode, &local); + const QQmlPropertyData *result = findProperty(object, qmlContext, name, revisionMode, &local); if (result) { if (revisionMode == QObjectWrapper::CheckRevision && result->hasRevision()) { @@ -455,7 +455,7 @@ bool QObjectWrapper::setQmlProperty( return false; QQmlPropertyData local; - QQmlPropertyData *result = QQmlPropertyCache::property(object, name, qmlContext, &local); + const QQmlPropertyData *result = QQmlPropertyCache::property(object, name, qmlContext, &local); if (!result) return false; @@ -491,7 +491,8 @@ void QObjectWrapper::setProperty( const QQmlPropertyCache *targetCache = QQmlData::get(targetObject)->propertyCache.data(); Q_ASSERT(targetCache); - QQmlPropertyData *targetProperty = targetCache->property(targetIndex.coreIndex()); + const QQmlPropertyData *targetProperty + = targetCache->property(targetIndex.coreIndex()); object = targetObject; property = targetProperty; return targetProperty->isVarProperty() || targetProperty->propType() == QMetaType::fromType<QJSValue>(); @@ -737,7 +738,7 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, int p return; Q_ASSERT(ddata->propertyCache); - QQmlPropertyData *property = ddata->propertyCache->property(propertyIndex); + const QQmlPropertyData *property = ddata->propertyCache->property(propertyIndex); Q_ASSERT(property); // We resolved this property earlier, so it better exist! return setProperty(engine, object, property, value); } @@ -940,10 +941,11 @@ ReturnedValue QObjectWrapper::virtualResolveLookupGetter(const Object *object, E QQmlData *ddata = QQmlData::get(qobj, false); if (!ddata || !ddata->propertyCache) { QQmlPropertyData local; - QQmlPropertyData *property = QQmlPropertyCache::property(qobj, name, qmlContext, &local); + const QQmlPropertyData *property = QQmlPropertyCache::property( + qobj, name, qmlContext, &local); return property ? getProperty(engine, qobj, property) : Encode::undefined(); } - QQmlPropertyData *property = ddata->propertyCache->property(name.getPointer(), qobj, qmlContext); + const QQmlPropertyData *property = ddata->propertyCache->property(name.getPointer(), qobj, qmlContext); if (!property) { // Check for attached properties diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 85f7502105..a4b3056276 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -110,7 +110,7 @@ DECLARE_HEAP_OBJECT(QObjectMethod, FunctionObject) { void init(QV4::ExecutionContext *scope); void destroy() { - if (methods != reinterpret_cast<QQmlPropertyData *>(&_singleMethod)) + if (methods != reinterpret_cast<const QQmlPropertyData *>(&_singleMethod)) delete[] methods; qObj.destroy(); FunctionObject::destroy(); @@ -167,10 +167,9 @@ struct Q_QML_EXPORT QObjectWrapper : public Object RevisionMode revisionMode, bool *hasProperty = nullptr, bool includeImports = false) const; \ - static ReturnedValue getQmlProperty( - ExecutionEngine *engine, const QQmlRefPointer<QQmlContextData> &qmlContext, + static ReturnedValue getQmlProperty(ExecutionEngine *engine, const QQmlRefPointer<QQmlContextData> &qmlContext, QObject *object, String *name, RevisionMode revisionMode, bool *hasProperty = nullptr, - QQmlPropertyData **property = nullptr); + const QQmlPropertyData **property = nullptr); static bool setQmlProperty( ExecutionEngine *engine, const QQmlRefPointer<QQmlContextData> &qmlContext, @@ -202,12 +201,10 @@ protected: static bool virtualIsEqualTo(Managed *that, Managed *o); static ReturnedValue create(ExecutionEngine *engine, QObject *object); - static QQmlPropertyData *findProperty( - QObject *o, const QQmlRefPointer<QQmlContextData> &qmlContext, + static const QQmlPropertyData *findProperty(QObject *o, const QQmlRefPointer<QQmlContextData> &qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local); - QQmlPropertyData *findProperty( - const QQmlRefPointer<QQmlContextData> &qmlContext, + const QQmlPropertyData *findProperty(const QQmlRefPointer<QQmlContextData> &qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const; static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); |