summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecompiler.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-11-16 00:15:05 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-11-16 00:15:05 (GMT)
commitf2cd51abd592a4da45892e42f0d38803e7c1620e (patch)
tree1bd051293840a4df04d1f82f95d9bd0fefb1796b /src/declarative/qml/qdeclarativecompiler.cpp
parentf809dc1b16d6a56c1a2d57997748bddb313f7f4c (diff)
downloadQt-f2cd51abd592a4da45892e42f0d38803e7c1620e.zip
Qt-f2cd51abd592a4da45892e42f0d38803e7c1620e.tar.gz
Qt-f2cd51abd592a4da45892e42f0d38803e7c1620e.tar.bz2
Treat easing.type: Easing.InOutQuad as a literal assignment, not binding
This was already being done for most enum assignments, but wasn't being done for value types. This patch extends the optimization for enums in a value type. Reviewed-by: Martin Jones
Diffstat (limited to 'src/declarative/qml/qdeclarativecompiler.cpp')
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index b2740b8..b371f52 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -1836,14 +1836,22 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
COMPILE_EXCEPTION(prop, tr("Unexpected object assignment"));
} else if (value->value.isScript()) {
// ### Check for writability
- BindingReference reference;
- reference.expression = value->value;
- reference.property = prop;
- reference.value = value;
- reference.bindingContext = ctxt;
- reference.bindingContext.owner++;
- addBindingReference(reference);
- value->type = Value::PropertyBinding;
+
+ //optimization for <Type>.<EnumValue> enum assignments
+ bool isEnumAssignment = false;
+ COMPILE_CHECK(testQualifiedEnumAssignment(p, obj, value, &isEnumAssignment));
+ if (isEnumAssignment) {
+ value->type = Value::Literal;
+ } else {
+ BindingReference reference;
+ reference.expression = value->value;
+ reference.property = prop;
+ reference.value = value;
+ reference.bindingContext = ctxt;
+ reference.bindingContext.owner++;
+ addBindingReference(reference);
+ value->type = Value::PropertyBinding;
+ }
} else {
COMPILE_CHECK(testLiteralAssignment(p, value));
value->type = Value::Literal;
@@ -2138,7 +2146,15 @@ bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop
QDeclarativeType *type = 0;
unit->imports().resolveType(typeName.toUtf8(), &type, 0, 0, 0, 0);
- if (!type || obj->typeName != type->qmlTypeName())
+ //handle enums on value types (where obj->typeName is empty)
+ QByteArray objTypeName = obj->typeName;
+ if (objTypeName.isEmpty()) {
+ QDeclarativeType *objType = toQmlType(obj);
+ if (objType)
+ objTypeName = objType->qmlTypeName();
+ }
+
+ if (!type || objTypeName != type->qmlTypeName())
return true;
QString enumValue = parts.at(1);