aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-01-08 17:48:27 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-01-18 14:54:21 +0100
commita1dbd28e89f055c191ca5580cea6f840017e52f1 (patch)
tree33dbd44cea9d29baf73ef5cb75b2c4e5cf7c62f4
parent6eb26fe88648265ff4f7f1508280a24bb2cb900d (diff)
QtQml: Move qmlType into base CU
Change-Id: I81ae9a4d24518dffc5b924994d45203958bb9546 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qml/common/qv4compileddata.cpp7
-rw-r--r--src/qml/common/qv4compileddata_p.h5
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit.cpp19
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit_p.h9
-rw-r--r--src/qml/qml/qqmlmetatype.cpp6
-rw-r--r--src/qml/qml/qqmlmetatypedata.cpp2
-rw-r--r--src/qml/qml/qqmlpropertycachecreator_p.h2
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp2
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp6
9 files changed, 32 insertions, 26 deletions
diff --git a/src/qml/common/qv4compileddata.cpp b/src/qml/common/qv4compileddata.cpp
index 38bd161db4..6087db9b92 100644
--- a/src/qml/common/qv4compileddata.cpp
+++ b/src/qml/common/qv4compileddata.cpp
@@ -206,6 +206,13 @@ bool CompilationUnit::verifyChecksum(const DependentTypesHasher &dependencyHashe
sizeof(data->dependencyMD5Checksum)) == 0;
}
+QQmlType CompilationUnit::qmlTypeForComponent(const QString &inlineComponentName) const
+{
+ if (inlineComponentName.isEmpty())
+ return qmlType;
+ return inlineComponentData[inlineComponentName].qmlType;
+}
+
} // namespace CompiledData
} // namespace QV4
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h
index b6e3b5f820..c03a504f0e 100644
--- a/src/qml/common/qv4compileddata_p.h
+++ b/src/qml/common/qv4compileddata_p.h
@@ -1490,6 +1490,8 @@ struct CompilationUnit final : public QQmlRefCounted<CompilationUnit>
QQmlPropertyCacheVector propertyCaches;
+ QQmlType qmlType;
+
public:
using CompiledObject = CompiledData::Object;
@@ -1649,6 +1651,9 @@ public:
bool verifyChecksum(const CompiledData::DependentTypesHasher &dependencyHasher) const;
+ QQmlType qmlTypeForComponent(const QString &inlineComponentName = QString()) const;
+ QMetaType metaType() const { return qmlType.typeId(); }
+
private:
QString m_fileName; // initialized from data->sourceFileIndex
QString m_finalUrlString; // initialized from data->finalUrlIndex
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp
index da44a9e104..efba61b8c9 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit.cpp
+++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp
@@ -254,10 +254,6 @@ void ExecutableCompilationUnit::clear()
delete [] imports;
imports = nullptr;
- // Clear the QQmlTypes but not the property caches.
- // The property caches may still be necessary to resolve further types.
- qmlType = QQmlType();
-
if (runtimeLookups) {
const uint lookupTableSize = unitData()->lookupTableSize;
for (uint i = 0; i < lookupTableSize; ++i)
@@ -377,9 +373,9 @@ void ExecutableCompilationUnit::finalizeCompositeType(const QQmlType &type)
if (m_compilationUnit->propertyCaches.needsVMEMetaObject(/*root object*/0)) {
// qmlType is only valid for types that have references to themselves.
if (type.isValid()) {
- qmlType = type;
+ m_compilationUnit->qmlType = type;
} else {
- qmlType = QQmlMetaType::findCompositeType(
+ m_compilationUnit->qmlType = QQmlMetaType::findCompositeType(
finalUrl(), this, (unitData()->flags & CompiledData::Unit::IsSingleton)
? QQmlMetaType::Singleton
: QQmlMetaType::NonSingleton);
@@ -391,9 +387,9 @@ void ExecutableCompilationUnit::finalizeCompositeType(const QQmlType &type)
auto *typeRef = m_compilationUnit->resolvedTypes.value(obj->inheritedTypeNameIndex);
Q_ASSERT(typeRef);
if (const auto compilationUnit = typeRef->compilationUnit())
- qmlType = compilationUnit->qmlType;
+ m_compilationUnit->qmlType = compilationUnit->m_compilationUnit->qmlType;
else
- qmlType = typeRef->type();
+ m_compilationUnit->qmlType = typeRef->type();
}
// Collect some data for instantiation later.
@@ -480,13 +476,6 @@ void ExecutableCompilationUnit::finalizeCompositeType(const QQmlType &type)
m_compilationUnit->m_totalObjectCount = objectCount;
}
-QQmlType ExecutableCompilationUnit::qmlTypeForComponent(const QString &inlineComponentName) const
-{
- if (inlineComponentName.isEmpty())
- return qmlType;
- return m_compilationUnit->inlineComponentData[inlineComponentName].qmlType;
-}
-
Heap::Module *ExecutableCompilationUnit::instantiate()
{
const CompiledData::Unit *data = m_compilationUnit->data;
diff --git a/src/qml/jsruntime/qv4executablecompilationunit_p.h b/src/qml/jsruntime/qv4executablecompilationunit_p.h
index 01a564eb23..694a067c1b 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit_p.h
+++ b/src/qml/jsruntime/qv4executablecompilationunit_p.h
@@ -134,9 +134,14 @@ public:
return m_compilationUnit->verifyChecksum(dependencyHasher);
}
- QQmlType qmlTypeForComponent(const QString &inlineComponentName = QString()) const;
+ QQmlType qmlTypeForComponent(const QString &inlineComponentName = QString()) const
+ {
+ return m_compilationUnit->qmlTypeForComponent(inlineComponentName);
+ }
+
+ QQmlType qmlType() const { return m_compilationUnit->qmlType; }
- QQmlType qmlType;
+ QMetaType metaType() const { return qmlType().typeId(); }
int inlineComponentId(const QString &inlineComponentName) const
{
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 22fb53b4e2..fe0d97077b 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1555,7 +1555,7 @@ static int doCountInternalCompositeTypeSelfReferences(
++result;
};
- doCheck(compilationUnit->qmlType.typeId().iface());
+ doCheck(compilationUnit->metaType().iface());
for (auto &&inlineData: compilationUnit->inlineComponentData())
doCheck(inlineData.qmlType.typeId().iface());
@@ -1945,7 +1945,7 @@ void QQmlMetaType::registerInternalCompositeType(
data->compositeTypes.insert(iface, compilationUnit);
};
- doInsert(compilationUnit->qmlType.typeId().iface());
+ doInsert(compilationUnit->metaType().iface());
for (auto &&inlineData: compilationUnit->inlineComponentData())
doInsert(inlineData.qmlType.typeId().iface());
}
@@ -1964,7 +1964,7 @@ void QQmlMetaType::unregisterInternalCompositeType(
data->compositeTypes.erase(it);
};
- doRemove(compilationUnit->qmlType.typeId().iface());
+ doRemove(compilationUnit->metaType().iface());
for (auto &&inlineData: compilationUnit->inlineComponentData())
doRemove(inlineData.qmlType.typeId().iface());
}
diff --git a/src/qml/qml/qqmlmetatypedata.cpp b/src/qml/qml/qqmlmetatypedata.cpp
index f8e420dc2d..198f18d1b2 100644
--- a/src/qml/qml/qqmlmetatypedata.cpp
+++ b/src/qml/qml/qqmlmetatypedata.cpp
@@ -242,7 +242,7 @@ QQmlPropertyCache::ConstPtr QQmlMetaTypeData::propertyCache(
static QQmlPropertyCache::ConstPtr propertyCacheForPotentialInlineComponentType(
QMetaType t, const QQmlMetaTypeData::CompositeTypes::const_iterator &iter) {
- if (t != (*iter)->qmlType.typeId()) {
+ if (t != (*iter)->metaType()) {
// this is an inline component, and what we have in the iterator is currently the parent compilation unit
for (auto &&icDatum: (*iter)->inlineComponentData())
if (icDatum.qmlType.typeId() == t)
diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h
index b84d589b39..414e7aa728 100644
--- a/src/qml/qml/qqmlpropertycachecreator_p.h
+++ b/src/qml/qml/qqmlpropertycachecreator_p.h
@@ -880,7 +880,7 @@ inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataFor
Q_ASSERT(type->isValid());
}
} else {
- *type = typeRef->compilationUnit()->qmlType.typeId();
+ *type = typeRef->compilationUnit()->metaType();
}
*version = typeRef->version();
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index c76a7a93c6..6218607027 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -410,7 +410,7 @@ static ReturnedValue instanceOfQObject(const QV4::QQmlTypeWrapper *typeWrapper,
QQmlEnginePrivate *qenginepriv = QQmlEnginePrivate::get(engine->qmlEngine());
QQmlRefPointer<QQmlTypeData> td = qenginepriv->typeLoader.getType(typeWrapper->d()->type().sourceUrl());
if (ExecutableCompilationUnit *cu = td->compilationUnit())
- myQmlType = QQmlMetaType::metaObjectForType(cu->qmlType.typeId());
+ myQmlType = QQmlMetaType::metaObjectForType(cu->metaType());
else
return Encode(false); // It seems myQmlType has some errors, so we could not compile it.
} else {
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 9df1e1c6ef..513e29b4f1 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -5800,7 +5800,7 @@ void tst_qqmllanguage::selfReference()
const QMetaObject *metaObject = o->metaObject();
QMetaProperty selfProperty = metaObject->property(metaObject->indexOfProperty("self"));
- QCOMPARE(selfProperty.metaType().id(), compilationUnit->qmlType.typeId().id());
+ QCOMPARE(selfProperty.metaType().id(), compilationUnit->metaType().id());
QByteArray typeName = selfProperty.typeName();
QVERIFY(typeName.endsWith('*'));
@@ -5809,7 +5809,7 @@ void tst_qqmllanguage::selfReference()
QMetaMethod selfFunction = metaObject->method(metaObject->indexOfMethod("returnSelf()"));
QVERIFY(selfFunction.isValid());
- QCOMPARE(selfFunction.returnType(), compilationUnit->qmlType.typeId().id());
+ QCOMPARE(selfFunction.returnType(), compilationUnit->metaType().id());
QMetaMethod selfSignal;
@@ -5823,7 +5823,7 @@ void tst_qqmllanguage::selfReference()
QVERIFY(selfSignal.isValid());
QCOMPARE(selfSignal.parameterCount(), 1);
- QCOMPARE(selfSignal.parameterType(0), compilationUnit->qmlType.typeId().id());
+ QCOMPARE(selfSignal.parameterType(0), compilationUnit->metaType().id());
}
void tst_qqmllanguage::selfReferencingSingleton()