From 1826cea72f73ec7f7ab2d834848537a249419974 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 26 Feb 2014 14:22:12 +0100 Subject: [new compiler] Fix property assignments to resolved enums Force the type of the property to write to int, if we resolved the enum earlier at type compile time. This is consistent with the VME and allows for assignments to enum properties without a string converter. Fixes tst_qquickgridview in particular. Change-Id: Ic29f4a6115930bd7fff45f1658c00d0bfc24c7ec Reviewed-by: Lars Knoll --- src/qml/qml/qqmlobjectcreator.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/qml/qml/qqmlobjectcreator.cpp') diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 07a570e0fa..ce4a8770de 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -219,16 +219,22 @@ void QQmlObjectCreator::setPropertyValue(QQmlPropertyData *property, const QV4:: QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::Scope scope(v4); - // ### This should be resolved earlier at compile time and the binding value should be changed accordingly. - if (property->isEnum() && !(binding->flags & QV4::CompiledData::Binding::IsResolvedEnum)) { - QVariant value = binding->valueAsString(&qmlUnit->header); - bool ok = QQmlPropertyPrivate::write(_qobject, *property, value, context); - Q_ASSERT(ok); - Q_UNUSED(ok); - return; + int propertyType = property->propType; + + if (property->isEnum()) { + if (binding->flags & QV4::CompiledData::Binding::IsResolvedEnum) { + propertyType = QMetaType::Int; + } else { + // ### This should be resolved earlier at compile time and the binding value should be changed accordingly. + QVariant value = binding->valueAsString(&qmlUnit->header); + bool ok = QQmlPropertyPrivate::write(_qobject, *property, value, context); + Q_ASSERT(ok); + Q_UNUSED(ok); + return; + } } - switch (property->propType) { + switch (propertyType) { case QMetaType::QVariant: { if (binding->type == QV4::CompiledData::Binding::Type_Number) { double n = binding->valueAsNumber(); -- cgit v1.2.3