diff options
author | Jędrzej Nowacki <jedrzej.nowacki@nokia.com> | 2011-11-16 14:43:28 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-16 15:46:26 +0100 |
commit | ea2e8abd5c655027da51548e0d0f2f55dfb947bc (patch) | |
tree | 57a5df55fc5358a2f035ae1b675537167f26d1d5 | |
parent | 92660b13bb138d219f49ea203fa5e5aed9de74cb (diff) |
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 <kai.koehne@nokia.com>
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<v8::Value> 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<v8::String> 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++))); |