From ea2e8abd5c655027da51548e0d0f2f55dfb947bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Wed, 16 Nov 2011 14:43:28 +0100 Subject: Fix console.log function. This patch fix problem of a truncated log message if it includes an object. The regression was introduced by a7f5c93de3f9811eef3f5a19ab6dec83b997e0d6. Change-Id: I080956ef3c902b6c4a57f5d0066c4616a449e661 Reviewed-by: Kai Koehne --- src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp | 8 +++++--- tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml | 2 ++ tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp b/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp index fed0569039..84b42f6d7f 100644 --- a/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp +++ b/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp @@ -97,12 +97,14 @@ v8::Handle console(ConsoleLogTypes logType, const v8::Arguments &args if (value->IsObject() && !value->IsFunction() && !value->IsArray() && !value->IsDate() && !value->IsRegExp()) { - result = QLatin1String("Object"); + result.append(QLatin1String("Object")); } else { v8::Local jsstr = value->ToString(); - result.append(V8ENGINE()->toString(jsstr)); + QString tmp = V8ENGINE()->toString(jsstr); if (value->IsArray()) - result = QString(QLatin1String("[%1]")).arg(result); + result.append(QString::fromLatin1("[%1]").arg(tmp)); + else + result.append(tmp); } } diff --git a/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml b/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml index afb758a21f..2692abb82e 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml @@ -25,6 +25,8 @@ QtObject { console.log(f) console.log(root) console.log(g) + console.log(1, "pong!", new Object) + console.log(1, ["ping","pong"], new Object, 2) console.log(exception) //This has to be at the end } } diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index c550ac2f5b..83bed2bf5b 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -484,6 +484,10 @@ void tst_qdeclarativeqt::consoleLog() QTest::ignoreMessage(QtDebugMsg, qPrintable(testBoolean.arg(startLineNumber++))); QTest::ignoreMessage(QtDebugMsg, qPrintable(testObject.arg(startLineNumber++))); QTest::ignoreMessage(QtDebugMsg, qPrintable(testObject.arg(startLineNumber++))); + QString testMix = QString::fromLatin1("1 pong! Object (%1:%2)").arg(testFileUrl.toString()); + QTest::ignoreMessage(QtDebugMsg, qPrintable(testMix.arg(startLineNumber++))); + testMix = QString::fromLatin1("1 [ping,pong] Object 2 (%1:%2)").arg(testFileUrl.toString()); + QTest::ignoreMessage(QtDebugMsg, qPrintable(testMix.arg(startLineNumber++))); QString testException = QString(QLatin1String("%1:%2: ReferenceError: Can't find variable: exception")).arg(testFileUrl.toString()); QTest::ignoreMessage(QtWarningMsg, qPrintable(testException.arg(startLineNumber++))); -- cgit v1.2.3