diff options
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 23 | ||||
-rw-r--r-- | tests/auto/qml/qqmlconsole/data/logging.qml | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp | 1 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index f713efb289..64dc581a56 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1527,6 +1527,27 @@ static QString jsStack(QV4::ExecutionEngine *engine) { return stack; } +static QString serializeArray(Object *array, ExecutionEngine *v4) { + Scope scope(v4); + ScopedValue val(scope); + QString result; + + result += QLatin1Char('['); + const uint length = array->getLength(); + for (uint i = 0; i < length; ++i) { + if (i != 0) + result += QLatin1Char(','); + val = array->get(i); + if (val->isManaged() && val->managed()->isArrayLike()) + result += serializeArray(val->objectValue(), v4); + else + result += val->toQStringNoThrow(); + } + result += QLatin1Char(']'); + + return result; +}; + static ReturnedValue writeToConsole(const FunctionObject *b, const Value *, const Value *argv, int argc, ConsoleLogTypes logType, bool printStack = false) { @@ -1554,7 +1575,7 @@ static ReturnedValue writeToConsole(const FunctionObject *b, const Value *, cons result.append(QLatin1Char(' ')); if (argv[i].isManaged() && argv[i].managed()->isArrayLike()) - result += QLatin1Char('[') + argv[i].toQStringNoThrow() + QLatin1Char(']'); + result.append(serializeArray(argv[i].objectValue(), v4)); else result.append(argv[i].toQStringNoThrow()); } diff --git a/tests/auto/qml/qqmlconsole/data/logging.qml b/tests/auto/qml/qqmlconsole/data/logging.qml index 8ed2dd73a1..1f929d311b 100644 --- a/tests/auto/qml/qqmlconsole/data/logging.qml +++ b/tests/auto/qml/qqmlconsole/data/logging.qml @@ -69,6 +69,7 @@ QtObject { console.log(contextStringListProperty); console.log(customObject); + console.log([[1,2,3,[2,2,2,2],4],[5,6,7,8]]); try { console.log(exception); diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp index f26eaa0817..b157314071 100644 --- a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp +++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp @@ -93,6 +93,7 @@ void tst_qqmlconsole::logging() QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] [object Object] 2"); QTest::ignoreMessage(QtDebugMsg, "[Hello,World]"); QTest::ignoreMessage(QtDebugMsg, "QVariant(CustomObject, MY OBJECT)"); + QTest::ignoreMessage(QtDebugMsg, "[[1,2,3,[2,2,2,2],4],[5,6,7,8]]"); QScopedPointer<QQmlContext> loggingContext(new QQmlContext(engine.rootContext())); QStringList stringList; stringList << QStringLiteral("Hello") << QStringLiteral("World"); |