diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-02-06 14:43:26 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-10 14:28:17 +0100 |
commit | 4cc230ade4df3919fbb9688b60e6e8f7f3cc8144 (patch) | |
tree | a6240d82988ec658d18be30e2ebf19bed2fc272d /src/qml/debugger/qv4profilerservice.cpp | |
parent | 77686f3b94dfd572778eb8dfa77717114e3abb93 (diff) |
Unify initial waiting of debug services
The debug services generally behave in one of two ways when initializing:
Either they block the initializing thread until some configuration is
passed over the network or they just go on. By introducing a generalized
configurable debug service the various ways of waiting on initialization
are cleaned up. The API defined for it also allows for engine-specific
initialization.
Change-Id: Id5685ef17d2a7eb1222629f7caa5ec53076d47b2
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/qml/debugger/qv4profilerservice.cpp')
-rw-r--r-- | src/qml/debugger/qv4profilerservice.cpp | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/qml/debugger/qv4profilerservice.cpp b/src/qml/debugger/qv4profilerservice.cpp index b064f57089..d8f69aecd9 100644 --- a/src/qml/debugger/qv4profilerservice.cpp +++ b/src/qml/debugger/qv4profilerservice.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qv4profilerservice_p.h" -#include "qqmldebugservice_p_p.h" +#include "qqmlconfigurabledebugservice_p_p.h" #include <QtCore/QHash> #include <QtCore/QMutex> @@ -81,7 +81,7 @@ QByteArray QV4ProfilerData::toByteArray() const return data; } -class QV4ProfilerServicePrivate : public QQmlDebugServicePrivate +class QV4ProfilerServicePrivate : public QQmlConfigurableDebugServicePrivate { Q_DECLARE_PUBLIC(QV4ProfilerService) @@ -99,23 +99,12 @@ public: QList<QV4ProfilerData> m_data; bool initialized; - QMutex initializeMutex; - QWaitCondition initializeCondition; QList<QString> m_ongoing; }; QV4ProfilerService::QV4ProfilerService(QObject *parent) - : QQmlDebugService(*(new QV4ProfilerServicePrivate()), QStringLiteral("V8Profiler"), 1, parent) + : QQmlConfigurableDebugService(*(new QV4ProfilerServicePrivate()), QStringLiteral("V8Profiler"), 1, parent) { - Q_D(QV4ProfilerService); - - QMutexLocker lock(&d->initializeMutex); - - if (registerService() == Enabled - && QQmlDebugService::blockingMode()) { - // let's wait for first message ... - d->initializeCondition.wait(&d->initializeMutex); - } } QV4ProfilerService::~QV4ProfilerService() @@ -130,6 +119,7 @@ QV4ProfilerService *QV4ProfilerService::instance() void QV4ProfilerService::stateAboutToBeChanged(QQmlDebugService::State newState) { Q_D(QV4ProfilerService); + QMutexLocker lock(configMutex()); if (state() == newState) return; @@ -140,10 +130,6 @@ void QV4ProfilerService::stateAboutToBeChanged(QQmlDebugService::State newState) Q_ARG(QString, title)); } QMetaObject::invokeMethod(this, "sendProfilingData", Qt::BlockingQueuedConnection); - } else { - // wake up constructor in blocking mode - // (we might got disabled before first message arrived) - d->initializeCondition.wakeAll(); } } @@ -157,7 +143,7 @@ void QV4ProfilerService::messageReceived(const QByteArray &message) QByteArray title; ds >> command >> option; - QMutexLocker lock(&d->initializeMutex); + QMutexLocker lock(configMutex()); if (command == "V8PROFILER") { ds >> title; @@ -180,7 +166,7 @@ void QV4ProfilerService::messageReceived(const QByteArray &message) } // wake up constructor in blocking mode - d->initializeCondition.wakeAll(); + stopWaiting(); QQmlDebugService::messageReceived(message); } |