From cd587fb494b465a4f30582099e0056164a8d1ca9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 16 Jul 2015 14:18:54 +0200 Subject: Make QQmlConfigurableDebugService a template We will need to derive from service-specific interfaces once we move the services into plugins and QQmlConfigurableDebugService doesn't need to live in QtQml. Change-Id: I151f32ea0f8be9719b245fc19164269c6e62a84a Reviewed-by: Simon Hausmann --- src/qml/debugger/qqmlconfigurabledebugservice_p.h | 47 +++++++++++++++++++---- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'src/qml/debugger/qqmlconfigurabledebugservice_p.h') diff --git a/src/qml/debugger/qqmlconfigurabledebugservice_p.h b/src/qml/debugger/qqmlconfigurabledebugservice_p.h index 28f0f4dfe2..1329591cba 100644 --- a/src/qml/debugger/qqmlconfigurabledebugservice_p.h +++ b/src/qml/debugger/qqmlconfigurabledebugservice_p.h @@ -47,21 +47,54 @@ // #include "qqmldebugservice_p.h" +#include "qqmldebugconnector_p.h" #include QT_BEGIN_NAMESPACE -class QQmlConfigurableDebugService : public QQmlDebugService +template +class QQmlConfigurableDebugService : public Base { - Q_OBJECT protected: - QQmlConfigurableDebugService(const QString &name, float version, QObject *parent = 0); + QQmlConfigurableDebugService(const QString &name, float version, QObject *parent = 0) : + Base(name, version, parent), m_configMutex(QMutex::Recursive) + { + init(); + } - void stopWaiting(); - void init(); + void stopWaiting() + { + QMutexLocker lock(&m_configMutex); + m_waitingForConfiguration = false; + foreach (QQmlEngine *engine, m_waitingEngines) + emit Base::attachedToEngine(engine); + m_waitingEngines.clear(); + } - void stateChanged(State); - void engineAboutToBeAdded(QQmlEngine *); + void init() + { + QMutexLocker lock(&m_configMutex); + // If we're not enabled or not blocking, don't wait for configuration + m_waitingForConfiguration = (Base::state() == QQmlDebugService::Enabled && + QQmlDebugConnector::instance()->blockingMode()); + } + + void stateChanged(QQmlDebugService::State newState) + { + if (newState != QQmlDebugService::Enabled) + stopWaiting(); + else + init(); + } + + void engineAboutToBeAdded(QQmlEngine *engine) + { + QMutexLocker lock(&m_configMutex); + if (m_waitingForConfiguration) + m_waitingEngines.append(engine); + else + emit Base::attachedToEngine(engine); + } QMutex m_configMutex; QList m_waitingEngines; -- cgit v1.2.3