Skip to content

Commit

Permalink
Fix console.log function.
Browse files Browse the repository at this point in the history
This patch fix problem of a truncated log message if it includes
an object. The regression was introduced by
a7f5c93.

Change-Id: I080956ef3c902b6c4a57f5d0066c4616a449e661
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
  • Loading branch information
nierob authored and Qt by Nokia committed Nov 16, 2011
1 parent 92660b1 commit ea2e8ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp
Expand Up @@ -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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml
Expand Up @@ -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
}
}
4 changes: 4 additions & 0 deletions tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
Expand Up @@ -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++)));
Expand Down

0 comments on commit ea2e8ab

Please sign in to comment.