aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlcompiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml/qqmlcompiler.cpp')
-rw-r--r--src/qml/qml/qqmlcompiler.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp
index 7a65515634..a5f1cc564f 100644
--- a/src/qml/qml/qqmlcompiler.cpp
+++ b/src/qml/qml/qqmlcompiler.cpp
@@ -815,7 +815,10 @@ bool QQmlCompiler::compile(QQmlEngine *engine,
const QQmlTypeData::TypeReference &tref = resolvedTypes.at(ii);
QQmlScript::TypeReference *parserRef = referencedTypes.at(ii);
- if (tref.type) {
+ if (tref.typeData) { //QML-based type
+ ref.component = tref.typeData->compiledData();
+ ref.component->addref();
+ } else if (tref.type) {//C++-based type
ref.type = tref.type;
if (!ref.type->isCreatable()) {
QString err = ref.type->noCreationReason();
@@ -823,21 +826,18 @@ bool QQmlCompiler::compile(QQmlEngine *engine,
err = tr( "Element is not creatable.");
COMPILE_EXCEPTION(parserRef->firstUse, err);
}
-
+
if (ref.type->containsRevisionedAttributes()) {
QQmlError cacheError;
ref.typePropertyCache = enginePrivate->cache(ref.type,
resolvedTypes.at(ii).minorVersion,
cacheError);
- if (!ref.typePropertyCache)
+ if (!ref.typePropertyCache)
COMPILE_EXCEPTION(parserRef->firstUse, cacheError.description());
ref.typePropertyCache->addref();
}
-
- } else if (tref.typeData) {
- ref.component = tref.typeData->compiledData();
- ref.component->addref();
}
+
out->types << ref;
}
@@ -944,7 +944,7 @@ void QQmlCompiler::compileTree(QQmlScript::Object *tree)
Q_ASSERT(tree->metatype);
if (!tree->synthdata.isEmpty()) {
- enginePrivate->registerCompositeType(output);
+ enginePrivate->registerInternalCompositeType(output);
} else if (output->types.at(tree->type).component) {
output->metaTypeId = output->types.at(tree->type).component->metaTypeId;
output->listMetaTypeId = output->types.at(tree->type).component->listMetaTypeId;
@@ -954,7 +954,7 @@ void QQmlCompiler::compileTree(QQmlScript::Object *tree)
output->listMetaTypeId = output->types.at(tree->type).type->qListTypeId();
}
if (!tree->synthdata.isEmpty())
- enginePrivate->registerCompositeType(output);
+ enginePrivate->registerInternalCompositeType(output);
}
static bool QStringList_contains(const QStringList &list, const QHashedStringRef &string)
@@ -1752,7 +1752,7 @@ bool QQmlCompiler::buildProperty(QQmlScript::Property *prop,
QQmlType *type = 0;
QQmlImportNamespace *typeNamespace = 0;
- unit->imports().resolveType(prop->name(), &type, 0, 0, 0, &typeNamespace);
+ unit->imports().resolveType(prop->name(), &type, 0, 0, &typeNamespace);
if (typeNamespace) {
COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj,
@@ -1874,7 +1874,7 @@ bool QQmlCompiler::buildPropertyInNamespace(QQmlImportNamespace *ns,
// Setup attached property data
QQmlType *type = 0;
- unit->imports().resolveType(ns, prop->name(), &type, 0, 0, 0);
+ unit->imports().resolveType(ns, prop->name(), &type, 0, 0);
if (!type || !type->attachedPropertiesType())
COMPILE_EXCEPTION(prop, tr("Non-existent attached object"));
@@ -2572,10 +2572,12 @@ bool QQmlCompiler::testQualifiedEnumAssignment(QQmlScript::Property *prop,
}
QQmlType *type = 0;
- unit->imports().resolveType(typeName, &type, 0, 0, 0, 0);
+ unit->imports().resolveType(typeName, &type, 0, 0, 0);
if (!type && typeName != QLatin1String("Qt"))
return true;
+ if (type && type->isComposite()) //No enums on composite types
+ return true;
int value = 0;
bool ok = false;
@@ -2619,7 +2621,7 @@ int QQmlCompiler::evaluateEnum(const QHashedStringRef &scope, const QByteArray&
if (scope != QLatin1String("Qt")) {
QQmlType *type = 0;
- unit->imports().resolveType(scope, &type, 0, 0, 0, 0);
+ unit->imports().resolveType(scope, &type, 0, 0, 0);
return type ? type->enumValue(QHashedCStringRef(enumValue.constData(), enumValue.length()), ok) : -1;
}
@@ -2636,7 +2638,7 @@ int QQmlCompiler::evaluateEnum(const QHashedStringRef &scope, const QByteArray&
const QMetaObject *QQmlCompiler::resolveType(const QString& name) const
{
QQmlType *qmltype = 0;
- if (!unit->imports().resolveType(name, &qmltype, 0, 0, 0, 0))
+ if (!unit->imports().resolveType(name, &qmltype, 0, 0, 0))
return 0;
if (!qmltype)
return 0;
@@ -3024,12 +3026,11 @@ bool QQmlCompiler::buildDynamicMeta(QQmlScript::Object *obj, DynamicMetaMode mod
// lazily resolved type
Q_ASSERT(s->parameterTypes.at(i) == Object::DynamicProperty::Custom);
QQmlType *qmltype = 0;
- QString url;
- if (!unit->imports().resolveType(s->parameterTypeNames.at(i).toString(), &qmltype, &url, 0, 0, 0))
+ if (!unit->imports().resolveType(s->parameterTypeNames.at(i).toString(), &qmltype, 0, 0, 0))
COMPILE_EXCEPTION(s, tr("Invalid signal parameter type: %1").arg(s->parameterTypeNames.at(i).toString()));
- if (!qmltype) {
- QQmlTypeData *tdata = enginePrivate->typeLoader.getType(QUrl(url));
+ if (qmltype->isComposite()) {
+ QQmlTypeData *tdata = enginePrivate->typeLoader.getType(qmltype->sourceUrl());
Q_ASSERT(tdata);
Q_ASSERT(tdata->isComplete());
@@ -3121,12 +3122,12 @@ bool QQmlCompiler::buildDynamicMeta(QQmlScript::Object *obj, DynamicMetaMode mod
p->type == Object::DynamicProperty::Custom);
QQmlType *qmltype = 0;
- QString url;
- if (!unit->imports().resolveType(p->customType.toString(), &qmltype, &url, 0, 0, 0))
+ if (!unit->imports().resolveType(p->customType.toString(), &qmltype, 0, 0, 0))
COMPILE_EXCEPTION(p, tr("Invalid property type"));
- if (!qmltype) {
- QQmlTypeData *tdata = enginePrivate->typeLoader.getType(QUrl(url));
+ Q_ASSERT(qmltype);
+ if (qmltype->isComposite()) {
+ QQmlTypeData *tdata = enginePrivate->typeLoader.getType(qmltype->sourceUrl());
Q_ASSERT(tdata);
Q_ASSERT(tdata->isComplete());
@@ -3885,7 +3886,7 @@ QQmlType *QQmlCompiler::toQmlType(QQmlScript::Object *from)
type = QQmlMetaType::qmlType(mo);
mo = mo->superClass();
}
- return type;
+ return type;
}
QStringList QQmlCompiler::deferredProperties(QQmlScript::Object *obj)