aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-02-27 21:48:18 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-02 20:52:08 +0100
commit189ddd88f94809942d92c2aa37b83cf65be8be4a (patch)
tree14f53033f66922bc4385f1307f2d412bd8e88b7a
parent52dc3f6937d51046424b232323189dfb41cc09c7 (diff)
[new compiler] Fix QQmlPropertyMap tests
QQmlPropertyMap is treated as a type that cannot be cached with QQmlPropertyCache, doesn't allow for accelerated property access and also doesn't allow for declarations of any kind in sub-types. Change-Id: Id8a6811120aa61ffb5037394e758cc62501e0fc3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp25
-rw-r--r--src/qml/qml/qqmlcompileddata.cpp2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp12
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h2
4 files changed, 34 insertions, 7 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index 2165f3d651..24234e83eb 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -127,6 +127,7 @@ bool QQmlTypeCompiler::compile()
}
ref->majorVersion = resolvedType->majorVersion;
ref->minorVersion = resolvedType->minorVersion;
+ ref->doDynamicTypeCheck();
compiledData->resolvedTypes.insert(resolvedType.key(), ref.take());
}
@@ -456,6 +457,22 @@ bool QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, int r
if (obj->inheritedTypeNameIndex != 0) {
QQmlCompiledData::TypeReference *typeRef = resolvedTypes->value(obj->inheritedTypeNameIndex);
Q_ASSERT(typeRef);
+
+ if (typeRef->isFullyDynamicType) {
+ if (obj->propertyCount() > 0) {
+ recordError(obj->location, tr("Fully dynamic types cannot declare new properties."));
+ return false;
+ }
+ if (obj->signalCount() > 0) {
+ recordError(obj->location, tr("Fully dynamic types cannot declare new signals."));
+ return false;
+ }
+ if (obj->functionCount() > 0) {
+ recordError(obj->location, tr("Fully Dynamic types cannot declare new functions."));
+ return false;
+ }
+ }
+
baseTypeCache = typeRef->createPropertyCache(QQmlEnginePrivate::get(enginePrivate));
Q_ASSERT(baseTypeCache);
} else if (instantiatingBinding && instantiatingBinding->isAttachedProperty()) {
@@ -2064,9 +2081,15 @@ bool QQmlJSCodeGenerator::compileComponent(int contextObject, const QHash<int, i
const int objectIndex = idIt.key();
JSCodeGen::IdMapping m;
- m.name = stringAt(qmlObjects.at(objectIndex)->idIndex);
+ const QtQml::QmlObject *obj = qmlObjects.at(objectIndex);
+ m.name = stringAt(obj->idIndex);
m.idIndex = idIt.value();
m.type = propertyCaches.at(objectIndex);
+
+ QQmlCompiledData::TypeReference *tref = resolvedTypes.value(obj->inheritedTypeNameIndex);
+ if (tref && tref->isFullyDynamicType)
+ m.type = 0;
+
idMapping << m;
}
diff --git a/src/qml/qml/qqmlcompileddata.cpp b/src/qml/qml/qqmlcompileddata.cpp
index 75740e17e6..aec4553d5d 100644
--- a/src/qml/qml/qqmlcompileddata.cpp
+++ b/src/qml/qml/qqmlcompileddata.cpp
@@ -193,7 +193,7 @@ void QQmlCompiledData::TypeReference::doDynamicTypeCheck()
mo = typePropertyCache->firstCppMetaObject();
else if (type)
mo = type->metaObject();
- else
+ else if (component)
mo = component->rootPropertyCache->firstCppMetaObject();
isFullyDynamicType = qtTypeInherits<QQmlPropertyMap>(mo);
}
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 68d128d79a..5f0b5f79be 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -952,6 +952,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent)
QObject *instance = 0;
QQmlCustomParser *customParser = 0;
QQmlParserStatus *parserStatus = 0;
+ bool installPropertyCache = true;
if (compiledData->isComponent(index)) {
isComponent = true;
@@ -963,6 +964,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent)
QQmlCompiledData::TypeReference *typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex);
Q_ASSERT(typeRef);
+ installPropertyCache = !typeRef->isFullyDynamicType;
QQmlType *type = typeRef->type;
if (type) {
instance = type->create();
@@ -1054,7 +1056,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent)
qSwap(_qmlContext, qmlContext);
- bool result = populateInstance(index, instance, cache, /*binding target*/instance, /*value type property*/0);
+ bool result = populateInstance(index, instance, cache, /*binding target*/instance, /*value type property*/0, installPropertyCache);
qSwap(_qmlContext, qmlContext);
qSwap(_scopeObject, scopeObject);
@@ -1134,7 +1136,7 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru
return sharedState->rootContext;
}
-bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache, QObject *bindingTarget, QQmlPropertyData *valueTypeProperty)
+bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache, QObject *bindingTarget, QQmlPropertyData *valueTypeProperty, bool installPropertyCache)
{
const QV4::CompiledData::Object *obj = qmlUnit->objectAt(index);
@@ -1162,8 +1164,10 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPo
} else {
vmeMetaObject = QQmlVMEMetaObject::get(_qobject);
}
- _ddata->propertyCache = _propertyCache;
- _ddata->propertyCache->addref();
+ if (installPropertyCache) {
+ _ddata->propertyCache = _propertyCache;
+ _ddata->propertyCache->addref();
+ }
_ddata->lineNumber = _compiledObject->location.line;
_ddata->columnNumber = _compiledObject->location.column;
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index 31fbbbd380..2545e45fb6 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -80,7 +80,7 @@ private:
QObject *createInstance(int index, QObject *parent = 0);
- bool populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache, QObject *bindingTarget, QQmlPropertyData *valueTypeProperty);
+ bool populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache, QObject *bindingTarget, QQmlPropertyData *valueTypeProperty, bool installPropertyCache = true);
void setupBindings();
bool setPropertyBinding(QQmlPropertyData *property, const QV4::CompiledData::Binding *binding);