Use const QQmlPropertyCache wherever possible

We're not supposed to modify property caches after they've been created.

Task-number: QTBUG-73271
Change-Id: I0ab8ed6750508fa4e28931995142f56cd5fa3061
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2022-03-10 11:44:27 +01:00
parent 4015665bbd
commit e5246cafff
29 changed files with 156 additions and 136 deletions

View File

@ -127,8 +127,8 @@ struct Q_QML_PRIVATE_EXPORT Lookup {
struct {
Heap::InternalClass *ic;
Heap::InternalClass *qmlTypeIc; // only used when lookup goes through QQmlTypeWrapper
QQmlPropertyCache *propertyCache;
QQmlPropertyData *propertyData;
const QQmlPropertyCache *propertyCache;
const QQmlPropertyData *propertyData;
} qobjectLookup;
struct {
quintptr isConstant; // This is a bool, encoded as 0 or 1. Both values are ignored by gc
@ -241,7 +241,7 @@ struct Q_QML_PRIVATE_EXPORT Lookup {
|| setter == setterQObject
|| qmlContextPropertyGetter == QQmlContextWrapper::lookupScopeObjectProperty
|| qmlContextPropertyGetter == QQmlContextWrapper::lookupContextObjectProperty) {
if (QQmlPropertyCache *pc = qobjectLookup.propertyCache)
if (const QQmlPropertyCache *pc = qobjectLookup.propertyCache)
pc->release();
}
}

View File

@ -255,7 +255,8 @@ QQmlPropertyData *QObjectWrapper::findProperty(
return result;
}
ReturnedValue QObjectWrapper::getProperty(ExecutionEngine *engine, QObject *object, QQmlPropertyData *property)
ReturnedValue QObjectWrapper::getProperty(
ExecutionEngine *engine, QObject *object, const QQmlPropertyData *property)
{
QQmlData::flushPendingBinding(object, property->coreIndex());
@ -487,7 +488,7 @@ void QObjectWrapper::setProperty(
const QQmlPropertyIndex originalIndex(property->coreIndex(), -1);
auto [targetObject, targetIndex] = QQmlPropertyPrivate::findAliasTarget(object, originalIndex);
Q_ASSERT(targetObject);
QQmlPropertyCache *targetCache
const QQmlPropertyCache *targetCache
= QQmlData::get(targetObject)->propertyCache.data();
Q_ASSERT(targetCache);
QQmlPropertyData *targetProperty = targetCache->property(targetIndex.coreIndex());
@ -756,7 +757,7 @@ bool QObjectWrapper::virtualIsEqualTo(Managed *a, Managed *b)
ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
{
if (QQmlRefPointer<QQmlPropertyCache> cache = QQmlData::ensurePropertyCache(object)) {
if (QQmlPropertyCache::ConstPtr cache = QQmlData::ensurePropertyCache(object)) {
ReturnedValue result = Encode::null();
void *args[] = { &result, &engine };
if (cache->callJSFactoryMethod(object, args))
@ -1131,7 +1132,7 @@ ReturnedValue QObjectWrapper::method_connect(const FunctionObject *b, const Valu
slot->function.set(scope.engine, f);
if (QQmlData *ddata = QQmlData::get(signalObject)) {
if (QQmlPropertyCache *propertyCache = ddata->propertyCache.data()) {
if (const QQmlPropertyCache *propertyCache = ddata->propertyCache.data()) {
QQmlPropertyPrivate::flushSignal(signalObject, propertyCache->methodIndexToSignalIndex(signalIndex));
}
}

View File

@ -189,7 +189,8 @@ struct Q_QML_EXPORT QObjectWrapper : public Object
void destroyObject(bool lastCall);
static ReturnedValue getProperty(ExecutionEngine *engine, QObject *object, QQmlPropertyData *property);
static ReturnedValue getProperty(
ExecutionEngine *engine, QObject *object, const QQmlPropertyData *property);
static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup);
static ReturnedValue lookupAttached(Lookup *l, ExecutionEngine *engine, const Value &object);
@ -253,7 +254,7 @@ inline ReturnedValue QObjectWrapper::lookupGetterImpl(Lookup *lookup, ExecutionE
if (!ddata)
return revertLookup();
QQmlPropertyData *property = lookup->qobjectLookup.propertyData;
const QQmlPropertyData *property = lookup->qobjectLookup.propertyData;
if (ddata->propertyCache.data() != lookup->qobjectLookup.propertyCache) {
if (property->isOverridden() && (!useOriginalProperty || property->isFunction() || property->isSignalHandler()))
return revertLookup();

View File

@ -72,7 +72,7 @@ void ResolvedTypeReference::doDynamicTypeCheck()
/*!
Returns the property cache, if one alread exists. The cache is not referenced.
*/
QQmlRefPointer<QQmlPropertyCache> ResolvedTypeReference::propertyCache() const
QQmlPropertyCache::ConstPtr ResolvedTypeReference::propertyCache() const
{
if (m_type.isValid())
return m_typePropertyCache;

View File

@ -73,7 +73,7 @@ public:
m_compilationUnit->release();
}
QQmlRefPointer<QQmlPropertyCache> propertyCache() const;
QQmlPropertyCache::ConstPtr propertyCache() const;
QQmlRefPointer<QQmlPropertyCache> createPropertyCache();
bool addToHash(QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums);
@ -114,7 +114,7 @@ public:
}
}
QQmlRefPointer<QQmlPropertyCache> typePropertyCache() const { return m_typePropertyCache; }
QQmlPropertyCache::ConstPtr typePropertyCache() const { return m_typePropertyCache; }
void setTypePropertyCache(QQmlRefPointer<QQmlPropertyCache> cache)
{
m_typePropertyCache = std::move(cache);

View File

@ -224,7 +224,7 @@ public:
QV4::WeakValue jsWrapper;
QQmlRefPointer<QQmlPropertyCache> propertyCache;
QQmlPropertyCache::ConstPtr propertyCache;
QQmlGuardImpl *guards;
@ -281,7 +281,7 @@ public:
static inline void flushPendingBinding(QObject *object, int coreIndex);
void flushPendingBinding(int coreIndex);
static QQmlRefPointer<QQmlPropertyCache> ensurePropertyCache(QObject *object)
static QQmlPropertyCache::ConstPtr ensurePropertyCache(QObject *object)
{
QQmlData *ddata = QQmlData::get(object, /*create*/true);
if (Q_LIKELY(ddata->propertyCache))
@ -297,7 +297,7 @@ private:
mutable QQmlDataExtended *extendedData;
Q_NEVER_INLINE static QQmlData *createQQmlData(QObjectPrivate *priv);
Q_NEVER_INLINE static QQmlRefPointer<QQmlPropertyCache> createPropertyCache(QObject *object);
Q_NEVER_INLINE static QQmlPropertyCache::ConstPtr createPropertyCache(QObject *object);
Q_ALWAYS_INLINE bool hasBitSet(int bit) const
{

View File

@ -1374,7 +1374,7 @@ QQmlData *QQmlData::createQQmlData(QObjectPrivate *priv)
return static_cast<QQmlData *>(priv->declarativeData);
}
QQmlRefPointer<QQmlPropertyCache> QQmlData::createPropertyCache(QObject *object)
QQmlPropertyCache::ConstPtr QQmlData::createPropertyCache(QObject *object)
{
QQmlData *ddata = QQmlData::get(object, /*create*/true);
ddata->propertyCache = QQmlMetaType::propertyCache(object, QTypeRevision {});

View File

@ -75,7 +75,7 @@ public:
inline QQmlMetaObject() = default;
inline QQmlMetaObject(const QObject *);
inline QQmlMetaObject(const QMetaObject *);
inline QQmlMetaObject(const QQmlRefPointer<QQmlPropertyCache> &);
inline QQmlMetaObject(const QQmlPropertyCache::ConstPtr &);
inline QQmlMetaObject(const QQmlMetaObject &);
inline QQmlMetaObject &operator=(const QQmlMetaObject &);
@ -127,7 +127,7 @@ QQmlMetaObject::QQmlMetaObject(const QMetaObject *m)
{
}
QQmlMetaObject::QQmlMetaObject(const QQmlRefPointer<QQmlPropertyCache> &m)
QQmlMetaObject::QQmlMetaObject(const QQmlPropertyCache::ConstPtr &m)
{
if (m)
_m = m->createMetaObject();

View File

@ -1316,7 +1316,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
return instance;
}
QQmlRefPointer<QQmlPropertyCache> cache = propertyCaches->at(index);
QQmlPropertyCache::ConstPtr cache = propertyCaches->at(index);
Q_ASSERT(!cache.isNull());
if (installPropertyCache)
ddata->propertyCache = cache;
@ -1505,7 +1505,7 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject *
QV4::Scope valueScope(v4);
QV4::ScopedValue scopeObjectProtector(valueScope);
QQmlRefPointer<QQmlPropertyCache> cache = propertyCaches->at(_compiledObjectIndex);
QQmlPropertyCache::ConstPtr cache = propertyCaches->at(_compiledObjectIndex);
QQmlVMEMetaObject *vmeMetaObject = nullptr;
if (propertyCaches->needsVMEMetaObject(_compiledObjectIndex)) {

View File

@ -228,7 +228,7 @@ private:
int _compiledObjectIndex;
const QV4::CompiledData::Object *_compiledObject;
QQmlData *_ddata;
QQmlRefPointer<QQmlPropertyCache> _propertyCache;
QQmlPropertyCache::ConstPtr _propertyCache;
QQmlVMEMetaObject *_vmeMetaObject;
QQmlListProperty<void> _currentList;
QV4::QmlContext *_qmlContext;
@ -244,7 +244,7 @@ private:
QQmlData *declarativeData = QQmlData::get(instance);
QObject *bindingTarget = instance;
QQmlRefPointer<QQmlPropertyCache> cache = declarativeData->propertyCache;
QQmlPropertyCache::ConstPtr cache = declarativeData->propertyCache;
QQmlVMEMetaObject *vmeMetaObject = QQmlVMEMetaObject::get(instance);
QObject *scopeObject = instance;

View File

@ -184,11 +184,10 @@ QQmlPropertyCache::~QQmlPropertyCache()
stringCache.clear();
}
QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCache::copy(
const QQmlMetaObjectPointer &mo, int reserve)
QQmlPropertyCache::Ptr QQmlPropertyCache::copy(const QQmlMetaObjectPointer &mo, int reserve) const
{
QQmlRefPointer<QQmlPropertyCache> cache = QQmlRefPointer<QQmlPropertyCache>(
new QQmlPropertyCache(mo), QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyCache::Ptr cache = QQmlPropertyCache::Ptr(
new QQmlPropertyCache(mo), QQmlPropertyCache::Ptr::Adopt);
cache->_parent.reset(this);
cache->propertyIndexCacheStart = propertyIndexCache.count() + propertyIndexCacheStart;
cache->methodIndexCacheStart = methodIndexCache.count() + methodIndexCacheStart;
@ -201,15 +200,15 @@ QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCache::copy(
return cache;
}
QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCache::copy()
QQmlPropertyCache::Ptr QQmlPropertyCache::copy() const
{
return copy(_metaObject, 0);
}
QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCache::copyAndReserve(
int propertyCount, int methodCount, int signalCount, int enumCount)
QQmlPropertyCache::Ptr QQmlPropertyCache::copyAndReserve(
int propertyCount, int methodCount, int signalCount, int enumCount) const
{
QQmlRefPointer<QQmlPropertyCache> rv = copy(
QQmlPropertyCache::Ptr rv = copy(
QQmlMetaObjectPointer(), propertyCount + methodCount + signalCount);
rv->propertyIndexCache.reserve(propertyCount);
rv->methodIndexCache.reserve(methodCount);
@ -353,25 +352,25 @@ QQmlPropertyData *QQmlPropertyCache::defaultProperty() const
return property(defaultPropertyName(), nullptr, nullptr);
}
void QQmlPropertyCache::setParent(QQmlRefPointer<QQmlPropertyCache> newParent)
void QQmlPropertyCache::setParent(QQmlPropertyCache::ConstPtr newParent)
{
if (_parent != newParent)
_parent = std::move(newParent);
}
QQmlRefPointer<QQmlPropertyCache>
QQmlPropertyCache::Ptr
QQmlPropertyCache::copyAndAppend(const QMetaObject *metaObject,
QTypeRevision typeVersion,
QQmlPropertyData::Flags propertyFlags,
QQmlPropertyData::Flags methodFlags,
QQmlPropertyData::Flags signalFlags)
QQmlPropertyData::Flags signalFlags) const
{
Q_ASSERT(QMetaObjectPrivate::get(metaObject)->revision >= 4);
// Reserve enough space in the name hash for all the methods (including signals), all the
// signal handlers and all the properties. This assumes no name clashes, but this is the
// common case.
QQmlRefPointer<QQmlPropertyCache> rv = copy(
QQmlPropertyCache::Ptr rv = copy(
metaObject,
QMetaObjectPrivate::get(metaObject)->methodCount
+ QMetaObjectPrivate::get(metaObject)->signalCount
@ -796,7 +795,7 @@ QString QQmlPropertyCache::signalParameterStringForJS(QV4::ExecutionEngine *engi
return parameters;
}
int QQmlPropertyCache::originalClone(int index)
int QQmlPropertyCache::originalClone(int index) const
{
while (signal(index)->isCloned())
--index;
@ -807,7 +806,7 @@ int QQmlPropertyCache::originalClone(const QObject *object, int index)
{
QQmlData *data = QQmlData::get(object);
if (data && data->propertyCache) {
QQmlPropertyCache *cache = data->propertyCache.data();
const QQmlPropertyCache *cache = data->propertyCache.data();
QQmlPropertyData *sig = cache->signal(index);
while (sig && sig->isCloned()) {
--index;
@ -899,7 +898,7 @@ QQmlPropertyData *
qQmlPropertyCacheProperty(QObject *obj, T name, const QQmlRefPointer<QQmlContextData> &context,
QQmlPropertyData *local)
{
QQmlPropertyCache *cache = nullptr;
const QQmlPropertyCache *cache = nullptr;
QQmlData *ddata = QQmlData::get(obj, false);

View File

@ -147,6 +147,18 @@ private:
class Q_QML_PRIVATE_EXPORT QQmlPropertyCache : public QQmlRefCount
{
public:
using Ptr = QQmlRefPointer<QQmlPropertyCache>;
struct ConstPtr : public QQmlRefPointer<const QQmlPropertyCache>
{
using QQmlRefPointer<const QQmlPropertyCache>::QQmlRefPointer;
ConstPtr(const Ptr &ptr) : ConstPtr(ptr.data(), AddRef) {}
ConstPtr(Ptr &&ptr) : ConstPtr(ptr.take(), Adopt) {}
ConstPtr &operator=(const Ptr &ptr) { return operator=(ConstPtr(ptr)); }
ConstPtr &operator=(Ptr &&ptr) { return operator=(ConstPtr(std::move(ptr))); }
};
QQmlPropertyCache() = default;
QQmlPropertyCache(const QMetaObject *, QTypeRevision metaObjectRevision = QTypeRevision::zero());
~QQmlPropertyCache() override;
@ -154,16 +166,16 @@ public:
void update(const QMetaObject *);
void invalidate(const QMetaObject *);
QQmlRefPointer<QQmlPropertyCache> copy();
QQmlPropertyCache::Ptr copy() const;
QQmlRefPointer<QQmlPropertyCache> copyAndAppend(
QQmlPropertyCache::Ptr copyAndAppend(
const QMetaObject *, QTypeRevision typeVersion,
QQmlPropertyData::Flags propertyFlags = QQmlPropertyData::Flags(),
QQmlPropertyData::Flags methodFlags = QQmlPropertyData::Flags(),
QQmlPropertyData::Flags signalFlags = QQmlPropertyData::Flags());
QQmlPropertyData::Flags signalFlags = QQmlPropertyData::Flags()) const;
QQmlRefPointer<QQmlPropertyCache> copyAndReserve(
int propertyCount, int methodCount, int signalCount, int enumCount);
QQmlPropertyCache::Ptr copyAndReserve(
int propertyCount, int methodCount, int signalCount, int enumCount) const;
void appendProperty(const QString &, QQmlPropertyData::Flags flags, int coreIndex,
QMetaType propType, QTypeRevision revision, int notifyIndex);
void appendSignal(const QString &, QQmlPropertyData::Flags, int coreIndex,
@ -196,10 +208,10 @@ public:
QQmlPropertyData *defaultProperty() const;
// Return a reference here so that we don't have to addref/release all the time
inline const QQmlRefPointer<QQmlPropertyCache> &parent() const;
inline const QQmlPropertyCache::ConstPtr &parent() const;
// is used by the Qml Designer
void setParent(QQmlRefPointer<QQmlPropertyCache> newParent);
void setParent(QQmlPropertyCache::ConstPtr newParent);
inline QQmlPropertyData *overrideData(QQmlPropertyData *) const;
inline bool isAllowedInRevision(QQmlPropertyData *) const;
@ -215,7 +227,7 @@ public:
QQmlPropertyData *);
//see QMetaObjectPrivate::originalClone
int originalClone(int index);
int originalClone(int index) const;
static int originalClone(const QObject *, int index);
QList<QByteArray> signalParameterNames(int index) const;
@ -253,7 +265,7 @@ private:
QQmlPropertyCache(const QQmlMetaObjectPointer &metaObject) : _metaObject(metaObject) {}
inline QQmlRefPointer<QQmlPropertyCache> copy(const QQmlMetaObjectPointer &mo, int reserve);
inline QQmlPropertyCache::Ptr copy(const QQmlMetaObjectPointer &mo, int reserve) const;
void append(const QMetaObject *, QTypeRevision typeVersion,
QQmlPropertyData::Flags propertyFlags = QQmlPropertyData::Flags(),
@ -311,7 +323,7 @@ private:
}
int propertyIndexCacheStart = 0; // placed here to avoid gap between QQmlRefCount and _parent
QQmlRefPointer<QQmlPropertyCache> _parent;
QQmlPropertyCache::ConstPtr _parent;
IndexCache propertyIndexCache;
IndexCache methodIndexCache;
@ -412,7 +424,7 @@ inline QString QQmlPropertyCache::defaultPropertyName() const
return _defaultPropertyName;
}
inline const QQmlRefPointer<QQmlPropertyCache> &QQmlPropertyCache::parent() const
inline const QQmlPropertyCache::ConstPtr &QQmlPropertyCache::parent() const
{
return _parent;
}

View File

@ -115,7 +115,7 @@ QQmlBindingInstantiationContext::QQmlBindingInstantiationContext(
int referencingObjectIndex,
const QV4::CompiledData::Binding *instantiatingBinding,
const QString &instantiatingPropertyName,
const QQmlRefPointer<QQmlPropertyCache> &referencingObjectPropertyCache)
const QQmlPropertyCache::ConstPtr &referencingObjectPropertyCache)
: referencingObjectIndex(referencingObjectIndex)
, instantiatingBinding(instantiatingBinding)
, instantiatingPropertyName(instantiatingPropertyName)

View File

@ -78,7 +78,7 @@ struct QQmlBindingInstantiationContext {
QQmlBindingInstantiationContext(
int referencingObjectIndex, const QV4::CompiledData::Binding *instantiatingBinding,
const QString &instantiatingPropertyName,
const QQmlRefPointer<QQmlPropertyCache> &referencingObjectPropertyCache);
const QQmlPropertyCache::ConstPtr &referencingObjectPropertyCache);
bool resolveInstantiatingProperty();
QQmlRefPointer<QQmlPropertyCache> instantiatingPropertyCache() const;
@ -86,13 +86,14 @@ struct QQmlBindingInstantiationContext {
int referencingObjectIndex = -1;
const QV4::CompiledData::Binding *instantiatingBinding = nullptr;
QString instantiatingPropertyName;
QQmlRefPointer<QQmlPropertyCache> referencingObjectPropertyCache;
QQmlPropertyCache::ConstPtr referencingObjectPropertyCache;
QQmlPropertyData *instantiatingProperty = nullptr;
};
struct QQmlPendingGroupPropertyBindings : public QVector<QQmlBindingInstantiationContext>
{
void resolveMissingPropertyCaches(QQmlPropertyCacheVector *propertyCaches) const;
void resolveMissingPropertyCaches(
QQmlPropertyCacheVector *propertyCaches) const;
};
struct QQmlPropertyCacheCreatorBase
@ -164,7 +165,7 @@ public:
protected:
QQmlError buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired);
QQmlRefPointer<QQmlPropertyCache> propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlError *error) const;
QQmlError createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache);
QQmlError createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlPropertyCache::ConstPtr &baseTypeCache);
QMetaType metaTypeForParameter(const QV4::CompiledData::ParameterType &param, QString *customTypeName = nullptr);
@ -309,7 +310,7 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectRecur
const CompiledObject *obj = objectContainer->objectAt(context.referencingObjectIndex);
auto *typeRef = objectContainer->resolvedType(obj->inheritedTypeNameIndex);
Q_ASSERT(typeRef);
QQmlRefPointer<QQmlPropertyCache> baseTypeCache = typeRef->createPropertyCache();
QQmlPropertyCache::ConstPtr baseTypeCache = typeRef->createPropertyCache();
QQmlError error = createMetaObject(context.referencingObjectIndex, obj, baseTypeCache);
if (error.isValid())
return error;
@ -341,7 +342,7 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectRecur
}
}
QQmlRefPointer<QQmlPropertyCache> thisCache = propertyCaches->at(objectIndex);
QQmlPropertyCache::ConstPtr thisCache = propertyCaches->at(objectIndex);
auto binding = obj->bindingsBegin();
auto end = obj->bindingsEnd();
for (; binding != end; ++binding) {
@ -445,9 +446,11 @@ inline QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCacheCreator<ObjectContaine
}
template <typename ObjectContainer>
inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache)
inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(
int objectIndex, const CompiledObject *obj,
const QQmlPropertyCache::ConstPtr &baseTypeCache)
{
QQmlRefPointer<QQmlPropertyCache> cache = baseTypeCache->copyAndReserve(
QQmlPropertyCache::Ptr cache = baseTypeCache->copyAndReserve(
obj->propertyCount() + obj->aliasCount(),
obj->functionCount() + obj->propertyCount() + obj->aliasCount() + obj->signalCount(),
obj->signalCount() + obj->propertyCount() + obj->aliasCount(),
@ -509,7 +512,7 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int
// and throw an error if there is a signal/method defined as an override.
QSet<QString> seenSignals;
seenSignals << QStringLiteral("destroyed") << QStringLiteral("parentChanged") << QStringLiteral("objectNameChanged");
QQmlPropertyCache *parentCache = cache.data();
const QQmlPropertyCache *parentCache = cache.data();
while ((parentCache = parentCache->parent().data())) {
if (int pSigCount = parentCache->signalCount()) {
int pSigOffset = parentCache->signalOffset();
@ -842,7 +845,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasPropertie
if (alias->encodedMetaPropertyIndex == -1)
continue;
const QQmlRefPointer<QQmlPropertyCache> targetCache
const QQmlPropertyCache::ConstPtr targetCache
= propertyCaches->at(targetObjectIndex);
Q_ASSERT(targetCache);
@ -962,7 +965,7 @@ inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataFor
int coreIndex = QQmlPropertyIndex::fromEncoded(alias.encodedMetaPropertyIndex).coreIndex();
int valueTypeIndex = QQmlPropertyIndex::fromEncoded(alias.encodedMetaPropertyIndex).valueTypeIndex();
QQmlRefPointer<QQmlPropertyCache> targetCache = propertyCaches->at(targetObjectIndex);
QQmlPropertyCache::ConstPtr targetCache = propertyCaches->at(targetObjectIndex);
Q_ASSERT(targetCache);
QQmlPropertyData *targetProperty = targetCache->property(coreIndex);
@ -972,7 +975,7 @@ inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataFor
if (!QQmlMetaType::isValueType(targetProperty->propType()) && valueTypeIndex != -1) {
// deep alias property
*type = targetProperty->propType();
QQmlRefPointer<QQmlPropertyCache> typeCache = QQmlMetaType::propertyCacheForType(*type);
QQmlPropertyCache::ConstPtr typeCache = QQmlMetaType::propertyCacheForType(*type);
Q_ASSERT(typeCache);
QQmlPropertyData *typeProperty = typeCache->property(valueTypeIndex);

View File

@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
struct Q_QML_EXPORT QQmlPropertyResolver
{
QQmlPropertyResolver(const QQmlRefPointer<QQmlPropertyCache> &cache)
QQmlPropertyResolver(const QQmlPropertyCache::ConstPtr &cache)
: cache(cache)
{}
@ -79,7 +79,7 @@ struct Q_QML_EXPORT QQmlPropertyResolver
// This code must match the semantics of QQmlPropertyPrivate::findSignalByName
QQmlPropertyData *signal(const QString &name, bool *notInRevision) const;
QQmlRefPointer<QQmlPropertyCache> cache;
QQmlPropertyCache::ConstPtr cache;
};
QT_END_NAMESPACE

View File

@ -114,7 +114,7 @@ QVector<QQmlError> QQmlPropertyValidator::validateObject(
return validateObject(componentBinding->value.objectIndex, componentBinding);
}
QQmlRefPointer<QQmlPropertyCache> propertyCache = propertyCaches.at(objectIndex);
QQmlPropertyCache::ConstPtr propertyCache = propertyCaches.at(objectIndex);
if (!propertyCache)
return QVector<QQmlError>();
@ -151,7 +151,7 @@ QVector<QQmlError> QQmlPropertyValidator::validateObject(
QString defaultPropertyName;
QQmlPropertyData *defaultProperty = nullptr;
if (obj->indexOfDefaultPropertyOrAlias != -1) {
QQmlPropertyCache *cache = propertyCache->parent().data();
const QQmlPropertyCache *cache = propertyCache->parent().data();
defaultPropertyName = cache->defaultPropertyName();
defaultProperty = cache->defaultProperty();
} else {
@ -380,7 +380,7 @@ QVector<QQmlError> QQmlPropertyValidator::validateObject(
}
QQmlError QQmlPropertyValidator::validateLiteralBinding(
const QQmlRefPointer<QQmlPropertyCache> &propertyCache, QQmlPropertyData *property,
const QQmlPropertyCache::ConstPtr &propertyCache, QQmlPropertyData *property,
const QV4::CompiledData::Binding *binding) const
{
if (property->isQList()) {
@ -659,9 +659,9 @@ QQmlError QQmlPropertyValidator::validateLiteralBinding(
Returns true if from can be assigned to a (QObject) property of type
to.
*/
bool QQmlPropertyValidator::canCoerce(QMetaType to, QQmlRefPointer<QQmlPropertyCache> fromMo) const
bool QQmlPropertyValidator::canCoerce(QMetaType to, QQmlPropertyCache::ConstPtr fromMo) const
{
QQmlRefPointer<QQmlPropertyCache> toMo = QQmlMetaType::rawPropertyCacheForType(to);
QQmlPropertyCache::ConstPtr toMo = QQmlMetaType::rawPropertyCacheForType(to);
if (toMo.isNull()) {
// if we have an inline component from the current file,
@ -710,7 +710,7 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *propert
const QV4::CompiledData::Object *targetObject = compilationUnit->objectAt(binding->value.objectIndex);
if (auto *typeRef = resolvedType(targetObject->inheritedTypeNameIndex)) {
QQmlRefPointer<QQmlPropertyCache> cache = typeRef->createPropertyCache();
QQmlPropertyCache::ConstPtr cache = typeRef->createPropertyCache();
const QMetaObject *mo = cache->firstCppMetaObject();
QQmlType qmlType;
while (mo && !qmlType.isValid()) {
@ -747,7 +747,7 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *propert
} else if (property->isQList()) {
const QMetaType listType = QQmlMetaType::listValueType(property->propType());
if (!QQmlMetaType::isInterface(listType)) {
QQmlRefPointer<QQmlPropertyCache> source = propertyCaches.at(binding->value.objectIndex);
QQmlPropertyCache::ConstPtr source = propertyCaches.at(binding->value.objectIndex);
if (!canCoerce(listType, source)) {
return qQmlCompileError(binding->valueLocation, tr("Cannot assign object to list property \"%1\"").arg(propertyName));
}
@ -771,7 +771,7 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *propert
// actual property type before we applied any extensions that might
// effect the properties on the type, but don't effect assignability
// Not passing a version ensures that we get the raw metaObject.
QQmlRefPointer<QQmlPropertyCache> propertyMetaObject
QQmlPropertyCache::ConstPtr propertyMetaObject
= QQmlMetaType::rawPropertyCacheForType(propType);
if (!propertyMetaObject) {
// if we have an inline component from the current file,
@ -790,7 +790,7 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *propert
// Will be true if the assigned type inherits propertyMetaObject
// Determine isAssignable value
bool isAssignable = false;
QQmlRefPointer<QQmlPropertyCache> c = propertyCaches.at(binding->value.objectIndex);
QQmlPropertyCache::ConstPtr c = propertyCaches.at(binding->value.objectIndex);
while (c && !isAssignable) {
isAssignable |= c == propertyMetaObject;
c = c->parent();

View File

@ -73,13 +73,13 @@ private:
int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding,
bool populatingValueTypeGroupProperty = false) const;
QQmlError validateLiteralBinding(
const QQmlRefPointer<QQmlPropertyCache> &propertyCache, QQmlPropertyData *property,
const QQmlPropertyCache::ConstPtr &propertyCache, QQmlPropertyData *property,
const QV4::CompiledData::Binding *binding) const;
QQmlError validateObjectBinding(
QQmlPropertyData *property, const QString &propertyName,
const QV4::CompiledData::Binding *binding) const;
bool canCoerce(QMetaType to, QQmlRefPointer<QQmlPropertyCache> fromMo) const;
bool canCoerce(QMetaType to, QQmlPropertyCache::ConstPtr fromMo) const;
Q_REQUIRED_RESULT QVector<QQmlError> recordError(
const QV4::CompiledData::Location &location, const QString &description) const;

View File

@ -185,7 +185,7 @@ QQmlType QQmlTypePrivate::resolveCompositeBaseType(QQmlEnginePrivate *engine) co
return QQmlMetaType::qmlType(mo);
}
QQmlRefPointer<QQmlPropertyCache> QQmlTypePrivate::compositePropertyCache(
QQmlPropertyCache::ConstPtr QQmlTypePrivate::compositePropertyCache(
QQmlEnginePrivate *engine) const
{
// similar logic to resolveCompositeBaseType
@ -276,9 +276,9 @@ void QQmlTypePrivate::init() const
void QQmlTypePrivate::initEnums(QQmlEnginePrivate *engine) const
{
QQmlRefPointer<QQmlPropertyCache> cache = (!isEnumFromCacheSetup.loadAcquire() && isComposite())
QQmlPropertyCache::ConstPtr cache = (!isEnumFromCacheSetup.loadAcquire() && isComposite())
? compositePropertyCache(engine)
: QQmlRefPointer<QQmlPropertyCache>();
: QQmlPropertyCache::ConstPtr();
// beware: It could be a singleton type without metaobject
const QMetaObject *metaObject = !isEnumFromBaseSetup.loadAcquire()
@ -415,11 +415,11 @@ void QQmlTypePrivate::createEnumConflictReport(const QMetaObject *metaObject, co
}
void QQmlTypePrivate::insertEnumsFromPropertyCache(
const QQmlRefPointer<QQmlPropertyCache> &cache) const
const QQmlPropertyCache::ConstPtr &cache) const
{
const QMetaObject *cppMetaObject = cache->firstCppMetaObject();
for (QQmlPropertyCache *currentCache = cache.data();
for (const QQmlPropertyCache *currentCache = cache.data();
currentCache && currentCache->metaObject() != cppMetaObject;
currentCache = currentCache->parent().data()) {

View File

@ -71,7 +71,7 @@ public:
void init() const;
void initEnums(QQmlEnginePrivate *engine) const;
void insertEnums(const QMetaObject *metaObject) const;
void insertEnumsFromPropertyCache(const QQmlRefPointer<QQmlPropertyCache> &cache) const;
void insertEnumsFromPropertyCache(const QQmlPropertyCache::ConstPtr &cache) const;
void setContainingType(QQmlType *containingType);
QUrl sourceUrl() const
@ -106,7 +106,7 @@ public:
}
QQmlType resolveCompositeBaseType(QQmlEnginePrivate *engine) const;
QQmlRefPointer<QQmlPropertyCache> compositePropertyCache(QQmlEnginePrivate *engine) const;
QQmlPropertyCache::ConstPtr compositePropertyCache(QQmlEnginePrivate *engine) const;
QQmlType::RegistrationType regType;

View File

@ -316,7 +316,7 @@ bool SignalHandlerResolver::resolveSignalHandlerExpressions()
{
for (int objectIndex = 0; objectIndex < qmlObjects.count(); ++objectIndex) {
const QmlIR::Object * const obj = qmlObjects.at(objectIndex);
QQmlRefPointer<QQmlPropertyCache> cache = propertyCaches->at(objectIndex);
QQmlPropertyCache::ConstPtr cache = propertyCaches->at(objectIndex);
if (!cache)
continue;
if (QQmlCustomParser *customParser = customParsers.value(obj->inheritedTypeNameIndex)) {
@ -332,7 +332,7 @@ bool SignalHandlerResolver::resolveSignalHandlerExpressions()
bool SignalHandlerResolver::resolveSignalHandlerExpressions(
const QmlIR::Object *obj, const QString &typeName,
const QQmlRefPointer<QQmlPropertyCache> &propertyCache)
const QQmlPropertyCache::ConstPtr &propertyCache)
{
// map from signal name defined in qml itself to list of parameters
QHash<QString, QStringList> customSignals;
@ -350,7 +350,7 @@ bool SignalHandlerResolver::resolveSignalHandlerExpressions(
const QMetaObject *attachedType = type.attachedPropertiesType(enginePrivate);
if (!attachedType)
COMPILE_EXCEPTION(binding, tr("Non-existent attached object"));
QQmlRefPointer<QQmlPropertyCache> cache = QQmlMetaType::propertyCache(attachedType);
QQmlPropertyCache::ConstPtr cache = QQmlMetaType::propertyCache(attachedType);
if (!resolveSignalHandlerExpressions(attachedObj, bindingPropertyName, cache))
return false;
continue;
@ -473,7 +473,7 @@ QQmlEnumTypeResolver::QQmlEnumTypeResolver(QQmlTypeCompiler *typeCompiler)
bool QQmlEnumTypeResolver::resolveEnumBindings()
{
for (int i = 0; i < qmlObjects.count(); ++i) {
QQmlRefPointer<QQmlPropertyCache> propertyCache = propertyCaches->at(i);
QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(i);
if (!propertyCache)
continue;
const QmlIR::Object *obj = qmlObjects.at(i);
@ -516,7 +516,7 @@ bool QQmlEnumTypeResolver::assignEnumToBinding(QmlIR::Binding *binding, QStringV
}
bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(
const QmlIR::Object *obj, const QQmlRefPointer<QQmlPropertyCache> &propertyCache,
const QmlIR::Object *obj, const QQmlPropertyCache::ConstPtr &propertyCache,
const QQmlPropertyData *prop, QmlIR::Binding *binding)
{
bool isIntProp = (prop->propType().id() == QMetaType::Int) && !prop->isEnum();
@ -695,7 +695,7 @@ QQmlAliasAnnotator::QQmlAliasAnnotator(QQmlTypeCompiler *typeCompiler)
void QQmlAliasAnnotator::annotateBindingsToAliases()
{
for (int i = 0; i < qmlObjects.count(); ++i) {
QQmlRefPointer<QQmlPropertyCache> propertyCache = propertyCaches->at(i);
QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(i);
if (!propertyCache)
continue;
@ -727,7 +727,7 @@ void QQmlScriptStringScanner::scan()
{
const QMetaType scriptStringMetaType = QMetaType::fromType<QQmlScriptString>();
for (int i = 0; i < qmlObjects.count(); ++i) {
QQmlRefPointer<QQmlPropertyCache> propertyCache = propertyCaches->at(i);
QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(i);
if (!propertyCache)
continue;
@ -777,7 +777,7 @@ static bool isUsableComponent(const QMetaObject *metaObject)
}
void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(
const QmlIR::Object *obj, const QQmlRefPointer<QQmlPropertyCache> &propertyCache)
const QmlIR::Object *obj, const QQmlPropertyCache::ConstPtr &propertyCache)
{
QQmlPropertyResolver propertyResolver(propertyCache);
@ -816,7 +816,7 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(
// If the version is given, use it and look up by QQmlType.
// Otherwise, make sure we look up by metaobject.
// TODO: Is this correct?
QQmlRefPointer<QQmlPropertyCache> pc = pd->typeVersion().hasMinorVersion()
QQmlPropertyCache::ConstPtr pc = pd->typeVersion().hasMinorVersion()
? QQmlMetaType::rawPropertyCacheForType(pd->propType(), pd->typeVersion())
: QQmlMetaType::rawPropertyCacheForType(pd->propType());
const QMetaObject *mo = pc ? pc->firstCppMetaObject() : nullptr;
@ -894,7 +894,7 @@ bool QQmlComponentAndAliasResolver::resolve(int root)
obj->flags & QV4::CompiledData::Object::IsInlineComponentRoot)
break; // left current inline component (potentially entered a new one)
}
QQmlRefPointer<QQmlPropertyCache> cache = propertyCaches.at(i);
QQmlPropertyCache::ConstPtr cache = propertyCaches.at(i);
if (obj->inheritedTypeNameIndex == 0 && !cache)
continue;
@ -1111,7 +1111,7 @@ QQmlComponentAndAliasResolver::resolveAliasesInObject(int objectIndex,
if (property.isEmpty()) {
alias->flags |= QV4::CompiledData::Alias::AliasPointsToPointerObject;
} else {
QQmlRefPointer<QQmlPropertyCache> targetCache = propertyCaches.at(targetObjectIndex);
QQmlPropertyCache::ConstPtr targetCache = propertyCaches.at(targetObjectIndex);
if (!targetCache) {
*error = qQmlCompileError(
alias->referenceLocation,
@ -1251,14 +1251,14 @@ bool QQmlDeferredAndCustomParserBindingScanner::scanObject(
return scanObject(componentBinding->value.objectIndex, ScopeDeferred::False);
}
QQmlRefPointer<QQmlPropertyCache> propertyCache = propertyCaches->at(objectIndex);
QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(objectIndex);
if (!propertyCache)
return true;
QString defaultPropertyName;
QQmlPropertyData *defaultProperty = nullptr;
if (obj->indexOfDefaultPropertyOrAlias != -1) {
QQmlPropertyCache *cache = propertyCache->parent().data();
const QQmlPropertyCache *cache = propertyCache->parent().data();
defaultPropertyName = cache->defaultPropertyName();
defaultProperty = cache->defaultProperty();
} else {
@ -1424,7 +1424,7 @@ void QQmlDefaultPropertyMerger::mergeDefaultProperties()
void QQmlDefaultPropertyMerger::mergeDefaultProperties(int objectIndex)
{
QQmlRefPointer<QQmlPropertyCache> propertyCache = propertyCaches->at(objectIndex);
QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(objectIndex);
if (!propertyCache)
return;

View File

@ -195,7 +195,7 @@ public:
private:
bool resolveSignalHandlerExpressions(const QmlIR::Object *obj, const QString &typeName,
const QQmlRefPointer<QQmlPropertyCache> &propertyCache);
const QQmlPropertyCache::ConstPtr &propertyCache);
QQmlEnginePrivate *enginePrivate;
const QVector<QmlIR::Object*> &qmlObjects;
@ -223,7 +223,7 @@ private:
return assignEnumToBinding(binding, QStringView(enumName), enumValue, isQtObject);
}
bool tryQualifiedEnumAssignment(
const QmlIR::Object *obj, const QQmlRefPointer<QQmlPropertyCache> &propertyCache,
const QmlIR::Object *obj, const QQmlPropertyCache::ConstPtr &propertyCache,
const QQmlPropertyData *prop, QmlIR::Binding *binding);
int evaluateEnum(const QString &scope, QStringView enumName, QStringView enumValue, bool *ok) const;
@ -281,7 +281,7 @@ public:
protected:
void findAndRegisterImplicitComponents(
const QmlIR::Object *obj, const QQmlRefPointer<QQmlPropertyCache> &propertyCache);
const QmlIR::Object *obj, const QQmlPropertyCache::ConstPtr &propertyCache);
bool collectIdsAndAliases(int objectIndex);
bool resolveAliases(int componentIndex);
void propertyDataForAlias(QmlIR::Alias *alias, int *type, quint32 *propertyFlags);

View File

@ -248,7 +248,7 @@ void QQmlVMEMetaObjectEndpoint::tryConnect()
const QQmlPropertyData *pd = targetDData->propertyCache->property(coreIndex);
if (pd && valueTypeIndex != -1 && !QQmlMetaType::valueType(pd->propType())) {
// deep alias
const QQmlRefPointer<QQmlPropertyCache> newPropertyCache
const QQmlPropertyCache::ConstPtr newPropertyCache
= QQmlMetaType::propertyCacheForType(pd->propType());
void *argv[1] = { &target };
QMetaObject::metacall(target, QMetaObject::ReadProperty, coreIndex, argv);
@ -267,7 +267,7 @@ void QQmlVMEMetaObjectEndpoint::tryConnect()
}
QQmlInterceptorMetaObject::QQmlInterceptorMetaObject(QObject *obj, const QQmlRefPointer<QQmlPropertyCache> &cache)
QQmlInterceptorMetaObject::QQmlInterceptorMetaObject(QObject *obj, const QQmlPropertyCache::ConstPtr &cache)
: object(obj),
cache(cache)
{
@ -404,7 +404,7 @@ QMetaObject *QQmlInterceptorMetaObject::toDynamicMetaObject(QObject *o)
QQmlVMEMetaObject::QQmlVMEMetaObject(QV4::ExecutionEngine *engine,
QObject *obj,
const QQmlRefPointer<QQmlPropertyCache> &cache, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &qmlCompilationUnit, int qmlObjectId)
const QQmlPropertyCache::ConstPtr &cache, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &qmlCompilationUnit, int qmlObjectId)
: QQmlInterceptorMetaObject(obj, cache),
engine(engine),
ctxt(QQmlData::get(obj, true)->outerContext),

View File

@ -93,7 +93,7 @@ private:
class Q_QML_PRIVATE_EXPORT QQmlInterceptorMetaObject : public QDynamicMetaObjectData
{
public:
QQmlInterceptorMetaObject(QObject *obj, const QQmlRefPointer<QQmlPropertyCache> &cache);
QQmlInterceptorMetaObject(QObject *obj, const QQmlPropertyCache::ConstPtr &cache);
~QQmlInterceptorMetaObject() override;
void registerInterceptor(QQmlPropertyIndex index, QQmlPropertyValueInterceptor *interceptor);
@ -103,7 +103,7 @@ public:
QMetaObject *toDynamicMetaObject(QObject *o) override;
// Used by auto-tests for inspection
QQmlRefPointer<QQmlPropertyCache> propertyCache() const { return cache; }
QQmlPropertyCache::ConstPtr propertyCache() const { return cache; }
bool intercepts(QQmlPropertyIndex propertyIndex) const
{
@ -117,7 +117,7 @@ public:
}
QObject *object = nullptr;
QQmlRefPointer<QQmlPropertyCache> cache;
QQmlPropertyCache::ConstPtr cache;
protected:
int metaCall(QObject *o, QMetaObject::Call c, int id, void **a) override;
@ -165,7 +165,7 @@ class Q_QML_PRIVATE_EXPORT QQmlVMEMetaObject : public QQmlInterceptorMetaObject
{
public:
QQmlVMEMetaObject(QV4::ExecutionEngine *engine, QObject *obj,
const QQmlRefPointer<QQmlPropertyCache> &cache,
const QQmlPropertyCache::ConstPtr &cache,
const QQmlRefPointer<QV4::ExecutableCompilationUnit> &qmlCompilationUnit,
int qmlObjectId);
~QQmlVMEMetaObject() override;

View File

@ -108,7 +108,7 @@ public:
virtual void fetchMore(QQmlAdaptorModel &) const {}
QScopedPointer<QMetaObject, QScopedPointerPodDeleter> metaObject;
QQmlRefPointer<QQmlPropertyCache> propertyCache;
QQmlPropertyCache::ConstPtr propertyCache;
};
const Accessors *accessors;

View File

@ -78,7 +78,7 @@ struct MetaPropertyData {
QVector<QPair<QVariant, bool> > m_data;
};
static QQmlRefPointer<QQmlPropertyCache> cacheForObject(QObject *object)
static QQmlPropertyCache::ConstPtr cacheForObject(QObject *object)
{
QQmlVMEMetaObject *metaObject = QQmlVMEMetaObject::get(object);
if (metaObject)
@ -118,7 +118,8 @@ void QQmlDesignerMetaObject::init(QObject *object)
QObjectPrivate *op = QObjectPrivate::get(object);
op->metaObject = this;
cache = QQmlMetaType::propertyCache(metaObject);
m_cache = QQmlMetaType::propertyCache(metaObject);
cache = m_cache;
nodeInstanceMetaObjectList.insert(this, true);
}
@ -133,9 +134,9 @@ QQmlDesignerMetaObject::QQmlDesignerMetaObject(QObject *object, QQmlEngine *engi
QQmlData *ddata = QQmlData::get(object, false);
//Assign cache to object
if (ddata && ddata->propertyCache) {
cache->setParent(ddata->propertyCache);
cache->invalidate(metaObject);
ddata->propertyCache = cache;
m_cache->setParent(ddata->propertyCache);
m_cache->invalidate(metaObject);
ddata->propertyCache = m_cache;
}
}
@ -156,7 +157,7 @@ void QQmlDesignerMetaObject::createNewDynamicProperty(const QString &name)
Q_ASSERT(id >= 0);
//Updating cache
cache->invalidate(metaObject);
m_cache->invalidate(metaObject);
QQmlProperty property(myObject(), name, m_context);
Q_ASSERT(property.isValid());

View File

@ -102,7 +102,10 @@ private:
QPointer<QQmlContext> m_context;
std::unique_ptr<QQmlOpenMetaObject> m_openMetaObject;
QScopedPointer<MetaPropertyData> m_data;
//QAbstractDynamicMetaObject *m_parent;
// This is non-const. You cannot use threads when using the designer metaobject.
// Otherwise it's the same as QQmlVMEMetaObject's "cache" member.
QQmlPropertyCache::Ptr m_cache;
friend class QQuickDesignerSupportProperties;
};

View File

@ -1441,7 +1441,7 @@ void QQuickShaderEffectImpl::updateShaderVars(Shader shaderType)
// Recreate signal mappers when the shader has changed.
clearMappers(shaderType);
QQmlRefPointer<QQmlPropertyCache> propCache = QQmlData::ensurePropertyCache(m_item);
QQmlPropertyCache::ConstPtr propCache = QQmlData::ensurePropertyCache(m_item);
if (!m_itemMetaObject)
m_itemMetaObject = m_item->metaObject();

View File

@ -4871,7 +4871,7 @@ void tst_qqmllanguage::preservePropertyCacheOnGroupObjects()
QQmlData *ddata = QQmlData::get(subObject);
QVERIFY(ddata);
QQmlPropertyCache *subCache = ddata->propertyCache.data();
const QQmlPropertyCache *subCache = ddata->propertyCache.data();
QVERIFY(subCache);
QQmlPropertyData *pd = subCache->property(QStringLiteral("newProperty"), /*object*/nullptr, /*context*/nullptr);
QVERIFY(pd);
@ -4888,7 +4888,7 @@ void tst_qqmllanguage::propertyCacheInSync()
QVERIFY(anchors);
QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(anchors);
QVERIFY(vmemo);
QQmlRefPointer<QQmlPropertyCache> vmemoCache = vmemo->propertyCache();
QQmlPropertyCache::ConstPtr vmemoCache = vmemo->propertyCache();
QVERIFY(vmemoCache);
QQmlData *ddata = QQmlData::get(anchors);
QVERIFY(ddata);

View File

@ -189,7 +189,7 @@ Q_SIGNALS:
void signalB();
};
QQmlPropertyData *cacheProperty(const QQmlRefPointer<QQmlPropertyCache> &cache, const char *name)
QQmlPropertyData *cacheProperty(const QQmlPropertyCache::ConstPtr &cache, const char *name)
{
return cache->property(QLatin1String(name), nullptr, nullptr);
}
@ -200,8 +200,8 @@ void tst_qqmlpropertycache::properties()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(metaObject),
QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyCache::ConstPtr cache(new QQmlPropertyCache(metaObject),
QQmlPropertyCache::ConstPtr::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cache, "propertyA")));
@ -223,10 +223,10 @@ void tst_qqmlpropertycache::propertiesDerived()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
QQmlRefPointer<QQmlPropertyCache> parentCache(
QQmlPropertyCache::ConstPtr parentCache(
new QQmlPropertyCache(&BaseObject::staticMetaObject),
QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlRefPointer<QQmlPropertyCache> cache =
QQmlPropertyCache::ConstPtr::Adopt);
QQmlPropertyCache::ConstPtr cache =
parentCache->copyAndAppend(object.metaObject(), QTypeRevision());
QQmlPropertyData *data;
@ -251,11 +251,11 @@ void tst_qqmlpropertycache::revisionedProperties()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
QQmlRefPointer<QQmlPropertyCache> cacheWithoutVersion(new QQmlPropertyCache(metaObject),
QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlRefPointer<QQmlPropertyCache> cacheWithVersion(
QQmlPropertyCache::ConstPtr cacheWithoutVersion(new QQmlPropertyCache(metaObject),
QQmlPropertyCache::ConstPtr::Adopt);
QQmlPropertyCache::ConstPtr cacheWithVersion(
new QQmlPropertyCache(metaObject, QTypeRevision::fromMinorVersion(1)),
QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyCache::ConstPtr::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cacheWithoutVersion, "propertyE")));
@ -269,8 +269,8 @@ void tst_qqmlpropertycache::methods()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(metaObject),
QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyCache::ConstPtr cache(new QQmlPropertyCache(metaObject),
QQmlPropertyCache::ConstPtr::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cache, "slotA")));
@ -304,10 +304,10 @@ void tst_qqmlpropertycache::methodsDerived()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
QQmlRefPointer<QQmlPropertyCache> parentCache(
QQmlPropertyCache::ConstPtr parentCache(
new QQmlPropertyCache(&BaseObject::staticMetaObject),
QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlRefPointer<QQmlPropertyCache> cache
QQmlPropertyCache::ConstPtr::Adopt);
QQmlPropertyCache::ConstPtr cache
= parentCache->copyAndAppend(object.metaObject(), QTypeRevision {});
QQmlPropertyData *data;
@ -342,8 +342,8 @@ void tst_qqmlpropertycache::signalHandlers()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(metaObject),
QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyCache::ConstPtr cache(new QQmlPropertyCache(metaObject),
QQmlPropertyCache::ConstPtr::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cache, "onSignalA")));
@ -371,10 +371,10 @@ void tst_qqmlpropertycache::signalHandlersDerived()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
QQmlRefPointer<QQmlPropertyCache> parentCache(
QQmlPropertyCache::ConstPtr parentCache(
new QQmlPropertyCache(&BaseObject::staticMetaObject),
QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlRefPointer<QQmlPropertyCache> cache
QQmlPropertyCache::ConstPtr::Adopt);
QQmlPropertyCache::ConstPtr cache
= parentCache->copyAndAppend(object.metaObject(), QTypeRevision{});
QQmlPropertyData *data;