aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-12-11 15:45:43 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-11 19:09:05 +0100
commitd9b934a1c115f6eac00b9b2564c908f7eecd196a (patch)
tree97b9aea689e8b87be78db44f3104dadc5a5989cb /src/qml
parent3ca143e2d46685e9e099f0448e77250d3a34d83c (diff)
Fix regression in QML string list concatenations
String lists and other QList property types (wrapped as QQmlSequence) should behave like arrays and have the Array prototype. Therefore it should be possible to pass them also as parameter to concat and they get composed correctly, i.e. the individual items get appended instead of the list being appened as one item. In the spec for concat this "special" casing should be applied if the "class internal property" is "Array", and concat appears to be the only place where this check is done. Therefore this patch adds another exception to match the expected behavior in QML and extends the "internal class is Array" meaning to QML list types. This is a regression from Qt <= 5.1.x Task-number: QTBUG-33149 Change-Id: Iab9522ac3c4ae6b746e790a99d87501b1cc1b655 Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index a8bc774e29..1628cfe4da 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -174,12 +174,22 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx)
}
ScopedArrayObject elt(scope);
+ ScopedObject eltAsObj(scope);
+ ScopedValue entry(scope);
for (int i = 0; i < ctx->callData->argc; ++i) {
+ eltAsObj = ctx->callData->args[i];
elt = ctx->callData->args[i];
- if (elt)
+ if (elt) {
result->arrayConcat(elt.getPointer());
- else
+ } else if (eltAsObj && eltAsObj->isListType()) {
+ const uint startIndex = getLength(ctx, result);
+ for (int i = 0, len = getLength(ctx, eltAsObj); i < len; ++i) {
+ entry = eltAsObj->getIndexed(i);
+ result->putIndexed(startIndex + i, entry);
+ }
+ } else {
result->arraySet(getLength(ctx, result), ctx->callData->args[i]);
+ }
}
return result.asReturnedValue();