Fix console.log function.
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>
Wed, 16 Nov 2011 13:43:28 +0000 (14:43 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 16 Nov 2011 14:46:26 +0000 (15:46 +0100)
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>
src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp
tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml
tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp

index fed0569..84b42f6 100644 (file)
@@ -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);
         }
     }
 
index afb758a..2692abb 100644 (file)
@@ -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
     }
 }
index c550ac2..83bed2b 100644 (file)
@@ -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++)));