diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-01-31 15:42:20 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-03 14:38:12 +0100 |
commit | 5d8a642f210e9b5a6187573ee75db6ca6c68c103 (patch) | |
tree | a5e4d3d158f291920942ce9d85b4bbb5da1e748d /src/qml/compiler | |
parent | d60251910eb3700f0f45e2fadf61dd457b094412 (diff) |
[new compiler] Fix error message when assigning lists to singular properties
Also adjust the error message for the other compiler when trying to assign
lists to script strings.
Change-Id: I50f833c340f3634a59c5b36f30aeafc53003e65e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qqmlcodegenerator.cpp | 2 | ||||
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 10 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 3 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp index f3b92fd27f..aeb2e95c2d 100644 --- a/src/qml/compiler/qqmlcodegenerator.cpp +++ b/src/qml/compiler/qqmlcodegenerator.cpp @@ -994,6 +994,8 @@ void QQmlCodeGenerator::appendBinding(const AST::SourceLocation &nameLocation, q if (isOnAssignment) binding->flags |= QV4::CompiledData::Binding::IsOnAssignment; + if (isListItem) + binding->flags |= QV4::CompiledData::Binding::IsListItem; binding->value.objectIndex = objectIndex; QString error = bindingsTarget()->appendBinding(binding, isListItem, bindingToDefaultProperty); diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 81b3e34ef4..c7cc3698aa 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -1455,6 +1455,16 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD return false; } + if (!pd->isQList() && (binding->flags & QV4::CompiledData::Binding::IsListItem)) { + QString error; + if (pd->propType == qMetaTypeId<QQmlScriptString>()) + error = tr( "Cannot assign multiple values to a script property"); + else + error = tr( "Cannot assign multiple values to a singular property"); + recordError(binding->valueLocation, error); + return false; + } + if (binding->type < QV4::CompiledData::Binding::Type_Script) { if (!validateLiteralBinding(propertyCache, pd, binding)) return false; diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 169f8449d4..77044ecdd8 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -297,7 +297,8 @@ struct Q_QML_EXPORT Binding IsSignalHandlerObject = 0x2, IsOnAssignment = 0x4, InitializerForReadOnlyDeclaration = 0x8, - IsResolvedEnum = 0x10 + IsResolvedEnum = 0x10, + IsListItem = 0x20 }; quint32 flags : 16; |