aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-30 20:04:37 +0100
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-12-15 15:59:57 +0000
commit63dede74a386012f9bd5a6896c3fd6ef6ffa01cd (patch)
tree11457288648f4d7ff2c0408546436aae4f2d9185 /src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
parent18c4295e25503ae637a715858de5c94a3d105a92 (diff)
QmlDebug: Add functionality to query if a server knows an engine
Change-Id: Iba40a1705c18d19c4ef5723aeb8ee5113e31041c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp')
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index 50c7ef3771..f6e805ca19 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -132,6 +132,7 @@ public:
void addEngine(QJSEngine *engine) Q_DECL_OVERRIDE;
void removeEngine(QJSEngine *engine) Q_DECL_OVERRIDE;
+ bool hasEngine(QJSEngine *engine) Q_DECL_OVERRIDE;
bool addService(const QString &name, QQmlDebugService *service) Q_DECL_OVERRIDE;
bool removeService(const QString &name) Q_DECL_OVERRIDE;
@@ -161,6 +162,7 @@ private:
EngineCondition() : numServices(0), condition(new QWaitCondition) {}
bool waitForServices(QMutex *locked, int numEngines);
+ bool isWaiting() const { return numServices > 0; }
void wake();
private:
@@ -565,6 +567,8 @@ void QQmlDebugServerImpl::addEngine(QJSEngine *engine)
Q_ASSERT(QThread::currentThread() != &m_thread);
QMutexLocker locker(&m_helloMutex);
+ Q_ASSERT(!m_engineConditions.contains(engine));
+
foreach (QQmlDebugService *service, m_plugins)
service->engineAboutToBeAdded(engine);
@@ -580,6 +584,8 @@ void QQmlDebugServerImpl::removeEngine(QJSEngine *engine)
Q_ASSERT(QThread::currentThread() != &m_thread);
QMutexLocker locker(&m_helloMutex);
+ Q_ASSERT(m_engineConditions.contains(engine));
+
foreach (QQmlDebugService *service, m_plugins)
service->engineAboutToBeRemoved(engine);
@@ -587,6 +593,16 @@ void QQmlDebugServerImpl::removeEngine(QJSEngine *engine)
foreach (QQmlDebugService *service, m_plugins)
service->engineRemoved(engine);
+
+ m_engineConditions.remove(engine);
+}
+
+bool QQmlDebugServerImpl::hasEngine(QJSEngine *engine)
+{
+ QMutexLocker locker(&m_helloMutex);
+ QHash<QJSEngine *, EngineCondition>::ConstIterator i = m_engineConditions.constFind(engine);
+ // if we're still waiting the engine isn't fully "there", yet, nor fully removed.
+ return i != m_engineConditions.constEnd() && !i.value().isWaiting();
}
bool QQmlDebugServerImpl::addService(const QString &name, QQmlDebugService *service)