diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-26 14:22:12 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-02 14:49:32 +0100 |
commit | 1826cea72f73ec7f7ab2d834848537a249419974 (patch) | |
tree | 34a2720a2754a89f99e35ebf077d3d5ae5a0c960 /src/qml/qml/qqmlobjectcreator.cpp | |
parent | 75989858270298fcd7153cb39af3c4a64c359833 (diff) |
[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 <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
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(); |