QmlProfiling: don't send v8 data if not profiling
authorChristiaan Janssen <christiaan.janssen@nokia.com>
Wed, 1 Feb 2012 15:47:26 +0000 (16:47 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 2 Feb 2012 00:14:50 +0000 (01:14 +0100)
Change-Id: I41085ed06bcf28e9de0a72f25076b91b9a3b2aea
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
src/declarative/debugger/qv8profilerservice.cpp
tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp

index 988ac65..3abec3f 100644 (file)
@@ -97,6 +97,7 @@ public:
     QList<QV8ProfilerData> m_data;
 
     bool initialized;
+    bool m_enabled;
 };
 
 QV8ProfilerService::QV8ProfilerService(QObject *parent)
@@ -104,6 +105,8 @@ QV8ProfilerService::QV8ProfilerService(QObject *parent)
 {
     Q_D(QV8ProfilerService);
 
+    d->m_enabled = false;
+
     if (registerService() == Enabled) {
         // ,block mode, client attached
         while (!d->initialized)
@@ -138,11 +141,13 @@ void QV8ProfilerService::messageReceived(const QByteArray &message)
 
     if (command == "V8PROFILER") {
         ds >>  title;
-        if (option == "start") {
+        if (option == "start" && !d->m_enabled) {
             QMetaObject::invokeMethod(this, "startProfiling", Qt::QueuedConnection, Q_ARG(QString, QString::fromUtf8(title)));
-        } else if (option == "stop") {
+            d->m_enabled = true;
+        } else if (option == "stop" && d->m_enabled) {
             QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, QString::fromUtf8(title)));
             QMetaObject::invokeMethod(this, "sendProfilingData", Qt::QueuedConnection);
+            d->m_enabled = false;
         }
         d->initialized = true;
     }
index 03d1406..c70d726 100644 (file)
@@ -216,9 +216,14 @@ void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
     connect(true);
     QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
 
-    m_client->startProfiling("");
     m_client->stopProfiling("");
+    if (QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()), 1000)) {
+        QString failMsg
+                = QString("Unexpected trace received! App output: %1\n\n").arg(m_process->output());
+        QFAIL(qPrintable(failMsg));
+    }
     m_client->startProfiling("");
+    m_client->stopProfiling("");
     if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
         QString failMsg
                 = QString("No trace received in time. App output: %1\n\n").arg(m_process->output());
@@ -231,8 +236,8 @@ void tst_QV8ProfilerService::nonBlockingConnect()
     connect(false);
     QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
 
-    m_client->stopProfiling("");
     m_client->startProfiling("");
+    m_client->stopProfiling("");
     if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
         QString failMsg
                 = QString("No trace received in time. App output: %1\n\n").arg(m_process->output());