From d19be6639999970105820d690952fee5b8e874ec Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Wed, 1 Feb 2012 16:47:26 +0100 Subject: QmlProfiling: don't send v8 data if not profiling Change-Id: I41085ed06bcf28e9de0a72f25076b91b9a3b2aea Reviewed-by: Aurindam Jana Reviewed-by: Kai Koehne --- src/declarative/debugger/qv8profilerservice.cpp | 9 +++++++-- .../debugger/qv8profilerservice/tst_qv8profilerservice.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/declarative/debugger/qv8profilerservice.cpp b/src/declarative/debugger/qv8profilerservice.cpp index 988ac65bfd..3abec3f6a2 100644 --- a/src/declarative/debugger/qv8profilerservice.cpp +++ b/src/declarative/debugger/qv8profilerservice.cpp @@ -97,6 +97,7 @@ public: QList 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; } diff --git a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp index 03d14062a8..c70d726fca 100644 --- a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp +++ b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp @@ -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()); -- cgit v1.2.3