aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp4
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp38
-rw-r--r--src/qml/compiler/qqmltypecompiler_p.h2
-rw-r--r--src/qml/qml/qqmlengine.cpp9
-rw-r--r--src/qml/qml/qqmlmetatype.cpp62
-rw-r--r--src/qml/qml/qqmlmetatype_p.h11
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp7
-rw-r--r--src/qml/qml/qqmlproperty.cpp10
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp5
-rw-r--r--tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml4
-rw-r--r--tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h2
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp16
-rw-r--r--tools/qmlplugindump/main.cpp21
14 files changed, 146 insertions, 51 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 7b0d4240c4..6fef1ae372 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -1615,10 +1615,10 @@ static QV4::IR::Type resolveQmlType(QQmlEnginePrivate *qmlEngine, QV4::IR::Membe
member->kind = QV4::IR::Member::MemberOfSingletonObject;
return resolver->resolveMember(qmlEngine, resolver, member);
}
- } else if (const QMetaObject *attachedMeta = type->attachedPropertiesType()) {
+ } else if (const QMetaObject *attachedMeta = type->attachedPropertiesType(qmlEngine)) {
QQmlPropertyCache *cache = qmlEngine->cache(attachedMeta);
initMetaObjectResolver(resolver, cache);
- member->setAttachedPropertiesId(type->attachedPropertiesId());
+ member->setAttachedPropertiesId(type->attachedPropertiesId(qmlEngine));
return resolver->resolveMember(qmlEngine, resolver, member);
}
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index e36ba76326..cde7a2acb4 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -520,7 +520,24 @@ bool QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, int r
} else if (instantiatingBinding && instantiatingBinding->isAttachedProperty()) {
QQmlCompiledData::TypeReference *typeRef = resolvedTypes->value(instantiatingBinding->propertyNameIndex);
Q_ASSERT(typeRef);
- const QMetaObject *attachedMo = typeRef->type ? typeRef->type->attachedPropertiesType() : 0;
+ QQmlType *qmltype = typeRef->type;
+ if (!qmltype) {
+ QString propertyName = stringAt(instantiatingBinding->propertyNameIndex);
+ if (imports->resolveType(propertyName, &qmltype, 0, 0, 0)) {
+ if (qmltype->isComposite()) {
+ QQmlTypeData *tdata = enginePrivate->typeLoader.getType(qmltype->sourceUrl());
+ Q_ASSERT(tdata);
+ Q_ASSERT(tdata->isComplete());
+
+ QQmlCompiledData *data = tdata->compiledData();
+ qmltype = QQmlMetaType::qmlType(data->metaTypeId);
+
+ tdata->release();
+ }
+ }
+ }
+
+ const QMetaObject *attachedMo = qmltype ? qmltype->attachedPropertiesType(enginePrivate) : 0;
if (!attachedMo) {
recordError(instantiatingBinding->location, tr("Non-existent attached object"));
return false;
@@ -880,7 +897,9 @@ bool QQmlPropertyCacheCreator::createMetaObject(int objectIndex, const QmlIR::Ob
SignalHandlerConverter::SignalHandlerConverter(QQmlTypeCompiler *typeCompiler)
: QQmlCompilePass(typeCompiler)
+ , enginePrivate(typeCompiler->enginePrivate())
, qmlObjects(*typeCompiler->qmlObjects())
+ , imports(typeCompiler->imports())
, customParsers(typeCompiler->customParserCache())
, resolvedTypes(*typeCompiler->resolvedTypes())
, illegalNames(QV8Engine::get(QQmlEnginePrivate::get(typeCompiler->enginePrivate()))->illegalNames())
@@ -918,7 +937,22 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio
const QmlIR::Object *attachedObj = qmlObjects.at(binding->value.objectIndex);
QQmlCompiledData::TypeReference *typeRef = resolvedTypes.value(binding->propertyNameIndex);
QQmlType *type = typeRef ? typeRef->type : 0;
- const QMetaObject *attachedType = type ? type->attachedPropertiesType() : 0;
+ if (!type) {
+ if (imports->resolveType(propertyName, &type, 0, 0, 0)) {
+ if (type->isComposite()) {
+ QQmlTypeData *tdata = enginePrivate->typeLoader.getType(type->sourceUrl());
+ Q_ASSERT(tdata);
+ Q_ASSERT(tdata->isComplete());
+
+ QQmlCompiledData *data = tdata->compiledData();
+ type = QQmlMetaType::qmlType(data->metaTypeId);
+
+ tdata->release();
+ }
+ }
+ }
+
+ const QMetaObject *attachedType = type ? type->attachedPropertiesType(enginePrivate) : 0;
if (!attachedType)
COMPILE_EXCEPTION(binding, tr("Non-existent attached object"));
QQmlPropertyCache *cache = compiler->enginePrivate()->cache(attachedType);
diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h
index 4bf9830014..c5be92d256 100644
--- a/src/qml/compiler/qqmltypecompiler_p.h
+++ b/src/qml/compiler/qqmltypecompiler_p.h
@@ -169,7 +169,9 @@ public:
private:
bool convertSignalHandlerExpressionsToFunctionDeclarations(const QmlIR::Object *obj, const QString &typeName, QQmlPropertyCache *propertyCache);
+ QQmlEnginePrivate *enginePrivate;
const QList<QmlIR::Object*> &qmlObjects;
+ const QQmlImports *imports;
const QHash<int, QQmlCustomParser*> &customParsers;
const QHash<int, QQmlCompiledData::TypeReference*> &resolvedTypes;
const QSet<QString> &illegalNames;
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 0c003790dd..be535025e6 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -1434,7 +1434,8 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre
if (rv || !create)
return rv;
- QQmlAttachedPropertiesFunc pf = QQmlMetaType::attachedPropertiesFuncById(id);
+ QQmlEnginePrivate *engine = QQmlEnginePrivate::get(data->context);
+ QQmlAttachedPropertiesFunc pf = QQmlMetaType::attachedPropertiesFuncById(engine, id);
if (!pf)
return 0;
@@ -1449,8 +1450,10 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre
QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
const QMetaObject *attachedMetaObject, bool create)
{
- if (*idCache == -1)
- *idCache = QQmlMetaType::attachedPropertiesFuncId(attachedMetaObject);
+ if (*idCache == -1) {
+ QQmlEngine *engine = object ? qmlEngine(object) : 0;
+ *idCache = QQmlMetaType::attachedPropertiesFuncId(engine ? QQmlEnginePrivate::get(engine) : 0, attachedMetaObject);
+ }
if (*idCache == -1 || !object)
return 0;
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 04c001d305..26271e3f03 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -474,18 +474,24 @@ QQmlType *QQmlType::superType() const
return d->superType;
}
-int QQmlType::resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const
+QQmlType *QQmlType::resolveCompositeBaseType(QQmlEnginePrivate *engine) const
{
Q_ASSERT(isComposite());
- *ok = false;
if (!engine)
- return -1;
+ return 0;
QQmlTypeData *td = engine->typeLoader.getType(sourceUrl());
if (!td || !td->isComplete())
- return -1;
+ return 0;
QQmlCompiledData *cd = td->compiledData();
const QMetaObject *mo = cd->rootPropertyCache->firstCppMetaObject();
- QQmlType *type = QQmlMetaType::qmlType(mo);
+ return QQmlMetaType::qmlType(mo);
+}
+
+int QQmlType::resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const
+{
+ Q_ASSERT(isComposite());
+ *ok = false;
+ QQmlType *type = resolveCompositeBaseType(engine);
if (!type)
return -1;
return type->enumValue(engine, name, ok);
@@ -856,18 +862,26 @@ int QQmlType::metaObjectRevision() const
return d->revision;
}
-QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction() const
+QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction(QQmlEnginePrivate *engine) const
{
- if (d->regType != CppType)
- return 0;
- return d->extraData.cd->attachedPropertiesFunc;
+ if (d->regType == CppType)
+ return d->extraData.cd->attachedPropertiesFunc;
+
+ QQmlType *base = 0;
+ if (d->regType == CompositeType)
+ base = resolveCompositeBaseType(engine);
+ return base ? base->attachedPropertiesFunction(engine) : 0;
}
-const QMetaObject *QQmlType::attachedPropertiesType() const
+const QMetaObject *QQmlType::attachedPropertiesType(QQmlEnginePrivate *engine) const
{
- if (d->regType != CppType)
- return 0;
- return d->extraData.cd->attachedPropertiesType;
+ if (d->regType == CppType)
+ return d->extraData.cd->attachedPropertiesType;
+
+ QQmlType *base = 0;
+ if (d->regType == CompositeType)
+ base = resolveCompositeBaseType(engine);
+ return base ? base->attachedPropertiesType(engine) : 0;
}
/*
@@ -875,11 +889,15 @@ This is the id passed to qmlAttachedPropertiesById(). This is different from th
for the case that a single class is registered under two or more names (eg. Item in
Qt 4.7 and QtQuick 1.0).
*/
-int QQmlType::attachedPropertiesId() const
+int QQmlType::attachedPropertiesId(QQmlEnginePrivate *engine) const
{
- if (d->regType != CppType)
- return 0;
- return d->extraData.cd->attachedPropertiesId;
+ if (d->regType == CppType)
+ return d->extraData.cd->attachedPropertiesId;
+
+ QQmlType *base = 0;
+ if (d->regType == CompositeType)
+ base = resolveCompositeBaseType(engine);
+ return base ? base->attachedPropertiesId(engine) : 0;
}
int QQmlType::parserStatusCast() const
@@ -1560,25 +1578,25 @@ int QQmlMetaType::listType(int id)
return 0;
}
-int QQmlMetaType::attachedPropertiesFuncId(const QMetaObject *mo)
+int QQmlMetaType::attachedPropertiesFuncId(QQmlEnginePrivate *engine, const QMetaObject *mo)
{
QMutexLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
QQmlType *type = data->metaObjectToType.value(mo);
- if (type && type->attachedPropertiesFunction())
- return type->attachedPropertiesId();
+ if (type && type->attachedPropertiesFunction(engine))
+ return type->attachedPropertiesId(engine);
else
return -1;
}
-QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFuncById(int id)
+QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFuncById(QQmlEnginePrivate *engine, int id)
{
if (id < 0)
return 0;
QMutexLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
- return data->types.at(id)->attachedPropertiesFunction();
+ return data->types.at(id)->attachedPropertiesFunction(engine);
}
QMetaProperty QQmlMetaType::defaultProperty(const QMetaObject *metaObject)
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 40765d461a..c120941a03 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -92,8 +92,8 @@ public:
static QObject *toQObject(const QVariant &, bool *ok = 0);
static int listType(int);
- static int attachedPropertiesFuncId(const QMetaObject *);
- static QQmlAttachedPropertiesFunc attachedPropertiesFuncById(int);
+ static int attachedPropertiesFuncId(QQmlEnginePrivate *engine, const QMetaObject *);
+ static QQmlAttachedPropertiesFunc attachedPropertiesFuncById(QQmlEnginePrivate *, int);
enum TypeCategory { Unknown, Object, List };
static TypeCategory typeCategory(int);
@@ -169,9 +169,9 @@ public:
int metaObjectRevision() const;
bool containsRevisionedAttributes() const;
- QQmlAttachedPropertiesFunc attachedPropertiesFunction() const;
- const QMetaObject *attachedPropertiesType() const;
- int attachedPropertiesId() const;
+ QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const;
+ const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const;
+ int attachedPropertiesId(QQmlEnginePrivate *engine) const;
int parserStatusCast() const;
const char *interfaceIId() const;
@@ -212,6 +212,7 @@ public:
int enumValue(QQmlEnginePrivate *engine, const QV4::String *, bool *ok) const;
private:
QQmlType *superType() const;
+ QQmlType *resolveCompositeBaseType(QQmlEnginePrivate *engine) const;
int resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const;
friend class QQmlTypePrivate;
friend struct QQmlMetaTypeData;
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 58c0b49b3c..c03a463c83 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -706,7 +706,12 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con
QQmlCompiledData::TypeReference *tr = resolvedTypes.value(binding->propertyNameIndex);
Q_ASSERT(tr);
QQmlType *attachedType = tr->type;
- const int id = attachedType->attachedPropertiesId();
+ if (!attachedType) {
+ QQmlTypeNameCache::Result res = context->imports->query(stringAt(binding->propertyNameIndex));
+ if (res.isValid())
+ attachedType = res.type;
+ }
+ const int id = attachedType->attachedPropertiesId(QQmlEnginePrivate::get(engine));
QObject *qmlObject = qmlAttachedPropertiesObjectById(id, _qobject);
if (!populateInstance(binding->value.objectIndex, qmlObject, qmlObject, /*value type property*/0))
return false;
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index d3f7070528..1b78ada698 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -248,10 +248,11 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
QQmlTypeNameCache::Result r = typeNameCache->query(pathName);
if (r.isValid()) {
if (r.type) {
- QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction();
+ QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine);
+ QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction(enginePrivate);
if (!func) return; // Not an attachable type
- currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(), currentObject);
+ currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(enginePrivate), currentObject);
if (!currentObject) return; // Something is broken with the attachable type
} else if (r.importNamespace) {
if ((ii + 1) == path.count()) return; // No type following the namespace
@@ -259,10 +260,11 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
++ii; r = typeNameCache->query(path.at(ii), r.importNamespace);
if (!r.type) return; // Invalid type in namespace
- QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction();
+ QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine);
+ QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction(enginePrivate);
if (!func) return; // Not an attachable type
- currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(), currentObject);
+ currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(enginePrivate), currentObject);
if (!currentObject) return; // Something is broken with the attachable type
} else if (r.scriptIndex != -1) {
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index d70a4019b2..6c29f2fbb5 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -185,7 +185,7 @@ ReturnedValue QmlTypeWrapper::get(const Managed *m, String *name, bool *hasPrope
// Fall through to base implementation
} else if (w->d()->object) {
- QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
+ QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(QQmlEnginePrivate::get(v4->qmlEngine())), object);
if (ao)
return QV4::QObjectWrapper::getQmlProperty(v4, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty);
@@ -241,7 +241,8 @@ void QmlTypeWrapper::put(Managed *m, String *name, const Value &value)
QQmlType *type = w->d()->type;
if (type && !type->isSingleton() && w->d()->object) {
QObject *object = w->d()->object;
- QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
+ QQmlEngine *e = scope.engine->qmlEngine();
+ QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(QQmlEnginePrivate::get(e)), object);
if (ao)
QV4::QObjectWrapper::setQmlProperty(v4, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, value);
} else if (type && type->isSingleton()) {
diff --git a/tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml
new file mode 100644
index 0000000000..6a14e72a31
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml
@@ -0,0 +1,4 @@
+import Test 1.0
+
+MyCompositeBaseType {
+}
diff --git a/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml b/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml
new file mode 100644
index 0000000000..d34e4650b3
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+RegisteredCompositeTypeWithAttachedProperty {
+ RegisteredCompositeTypeWithAttachedProperty.objectName: "test"
+ property string attachedProperty: RegisteredCompositeTypeWithAttachedProperty.objectName
+}
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 985acc2539..c64fda5ea1 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -1086,6 +1086,7 @@ class MyCompositeBaseType : public QObject
public:
enum CompositeEnum { EnumValue0, EnumValue42 = 42 };
+ static QObject *qmlAttachedProperties(QObject *parent) { return new QObject(parent); }
};
Q_DECLARE_METATYPE(MyEnum2Class::EnumB)
@@ -1100,6 +1101,7 @@ QML_DECLARE_TYPE(MyRevisionedSubclass)
QML_DECLARE_TYPE(MySubclass)
QML_DECLARE_TYPE(MyReceiversTestObject)
QML_DECLARE_TYPE(MyCompositeBaseType)
+QML_DECLARE_TYPEINFO(MyCompositeBaseType, QML_HAS_ATTACHED_PROPERTIES)
class CustomBinding : public QObject, public QQmlParserStatus
{
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index b48f3640f4..54e9c361e4 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -160,6 +160,7 @@ private slots:
void receivers();
void registeredCompositeType();
void registeredCompositeTypeWithEnum();
+ void registeredCompositeTypeWithAttachedProperty();
void implicitImportsLast();
void basicRemote_data();
@@ -3176,6 +3177,7 @@ void tst_qqmllanguage::initTestCase()
qmlRegisterType(testFileUrl("CompositeType.DoesNotExist.qml"), "Test", 1, 0, "RegisteredCompositeType2");
qmlRegisterType(testFileUrl("invalidRoot.1.qml"), "Test", 1, 0, "RegisteredCompositeType3");
qmlRegisterType(testFileUrl("CompositeTypeWithEnum.qml"), "Test", 1, 0, "RegisteredCompositeTypeWithEnum");
+ qmlRegisterType(testFileUrl("CompositeTypeWithAttachedProperty.qml"), "Test", 1, 0, "RegisteredCompositeTypeWithAttachedProperty");
// Registering the TestType class in other modules should have no adverse effects
qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test");
@@ -3367,6 +3369,20 @@ void tst_qqmllanguage::registeredCompositeTypeWithEnum()
delete o;
}
+// QTBUG-43581
+void tst_qqmllanguage::registeredCompositeTypeWithAttachedProperty()
+{
+ QQmlComponent component(&engine, testFileUrl("registeredCompositeTypeWithAttachedProperty.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("attachedProperty").toString(), QStringLiteral("test"));
+
+ delete o;
+}
+
// QTBUG-18268
void tst_qqmllanguage::remoteLoadCrash()
{
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index 0238a4aaae..5d1864a746 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -32,6 +32,7 @@
****************************************************************************/
#include <QtQml/qqmlengine.h>
+#include <QtQml/private/qqmlengine_p.h>
#include <QtQml/private/qqmlmetatype_p.h>
#include <QtQml/private/qqmlopenmetaobject_p.h>
#include <QtQuick/private/qquickevents_p_p.h>
@@ -129,11 +130,11 @@ void collectReachableMetaObjects(QObject *object, QSet<const QMetaObject *> *met
}
}
-void collectReachableMetaObjects(const QQmlType *ty, QSet<const QMetaObject *> *metas)
+void collectReachableMetaObjects(QQmlEnginePrivate *engine, const QQmlType *ty, QSet<const QMetaObject *> *metas)
{
collectReachableMetaObjects(ty->metaObject(), metas, ty->isExtendedType());
- if (ty->attachedPropertiesType())
- collectReachableMetaObjects(ty->attachedPropertiesType(), metas);
+ if (ty->attachedPropertiesType(engine))
+ collectReachableMetaObjects(ty->attachedPropertiesType(engine), metas);
}
/* We want to add the MetaObject for 'Qt' to the list, this is a
@@ -195,11 +196,11 @@ QByteArray convertToId(const QMetaObject *mo)
// Collect all metaobjects for types registered with qmlRegisterType() without parameters
-void collectReachableMetaObjectsWithoutQmlName( QSet<const QMetaObject *>& metas ) {
+void collectReachableMetaObjectsWithoutQmlName(QQmlEnginePrivate *engine, QSet<const QMetaObject *>& metas ) {
foreach (const QQmlType *ty, QQmlMetaType::qmlAllTypes()) {
if ( ! metas.contains(ty->metaObject()) ) {
if (!ty->isComposite()) {
- collectReachableMetaObjects(ty, &metas);
+ collectReachableMetaObjects(engine, ty, &metas);
} else {
qmlTypesByCompositeName[ty->elementName()] = ty;
}
@@ -225,7 +226,7 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine,
qmlTypesByCppName[ty->metaObject()->className()].insert(ty);
if (ty->isExtendedType())
extensions[ty->typeName()].insert(ty->metaObject()->className());
- collectReachableMetaObjects(ty, &metas);
+ collectReachableMetaObjects(QQmlEnginePrivate::get(engine), ty, &metas);
} else {
qmlTypesByCompositeName[ty->elementName()] = ty;
}
@@ -324,7 +325,7 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine,
}
}
- collectReachableMetaObjectsWithoutQmlName(metas);
+ collectReachableMetaObjectsWithoutQmlName(QQmlEnginePrivate::get(engine), metas);
return metas;
}
@@ -510,7 +511,7 @@ public:
qml->writeEndObject();
}
- void dump(const QMetaObject *meta, bool isUncreatable, bool isSingleton)
+ void dump(QQmlEnginePrivate *engine, const QMetaObject *meta, bool isUncreatable, bool isSingleton)
{
qml->writeStartObject("Component");
@@ -556,7 +557,7 @@ public:
}
qml->writeArrayBinding(QLatin1String("exportMetaObjectRevisions"), metaObjectRevisions);
- if (const QMetaObject *attachedType = (*qmlTypes.begin())->attachedPropertiesType()) {
+ if (const QMetaObject *attachedType = (*qmlTypes.begin())->attachedPropertiesType(engine)) {
// Can happen when a type is registered that returns itself as attachedPropertiesType()
// because there is no creatable type to attach to.
if (attachedType != meta) {
@@ -1173,7 +1174,7 @@ int main(int argc, char *argv[])
if (relocatable)
dumper.setRelocatableModuleUri(pluginImportUri);
foreach (const QMetaObject *meta, nameToMeta) {
- dumper.dump(meta, uncreatableMetas.contains(meta), singletonMetas.contains(meta));
+ dumper.dump(QQmlEnginePrivate::get(&engine), meta, uncreatableMetas.contains(meta), singletonMetas.contains(meta));
}
foreach (const QQmlType *compositeType, qmlTypesByCompositeName)
dumper.dumpComposite(&engine, compositeType, defaultReachableNames);