aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger/qqmlconfigurabledebugservice_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-16 14:18:54 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-31 11:31:14 +0000
commitcd587fb494b465a4f30582099e0056164a8d1ca9 (patch)
tree6c7a3bc222ddfc2102bb8dd8c4c21d92721d7df3 /src/qml/debugger/qqmlconfigurabledebugservice_p.h
parente061150cc54255726b8cda8cc928d3ed03ea8093 (diff)
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 <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/debugger/qqmlconfigurabledebugservice_p.h')
-rw-r--r--src/qml/debugger/qqmlconfigurabledebugservice_p.h47
1 files changed, 40 insertions, 7 deletions
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 <QtCore/qmutex.h>
QT_BEGIN_NAMESPACE
-class QQmlConfigurableDebugService : public QQmlDebugService
+template <class Base>
+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<QQmlEngine *> m_waitingEngines;