aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
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
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')
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp13
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp16
3 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
index e4054e100d..93e01b3824 100644
--- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
@@ -225,6 +225,8 @@ QQmlDebugService *QQmlNativeDebugConnector::service(const QString &name) const
void QQmlNativeDebugConnector::addEngine(QJSEngine *engine)
{
+ Q_ASSERT(!m_engines.contains(engine));
+
TRACE_PROTOCOL("Add engine to connector:" << engine);
foreach (QQmlDebugService *service, m_services)
service->engineAboutToBeAdded(engine);
@@ -233,10 +235,14 @@ void QQmlNativeDebugConnector::addEngine(QJSEngine *engine)
foreach (QQmlDebugService *service, m_services)
service->engineAdded(engine);
+
+ m_engines.append(engine);
}
void QQmlNativeDebugConnector::removeEngine(QJSEngine *engine)
{
+ Q_ASSERT(m_engines.contains(engine));
+
TRACE_PROTOCOL("Remove engine from connector:" << engine);
foreach (QQmlDebugService *service, m_services)
service->engineAboutToBeRemoved(engine);
@@ -245,6 +251,13 @@ void QQmlNativeDebugConnector::removeEngine(QJSEngine *engine)
foreach (QQmlDebugService *service, m_services)
service->engineRemoved(engine);
+
+ m_engines.removeOne(engine);
+}
+
+bool QQmlNativeDebugConnector::hasEngine(QJSEngine *engine)
+{
+ return m_engines.contains(engine);
}
void QQmlNativeDebugConnector::announceObjectAvailability(const QString &objectType,
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h
index a883608fd4..5b1bc90478 100644
--- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h
@@ -51,6 +51,7 @@ public:
QQmlDebugService *service(const QString &name) const Q_DECL_OVERRIDE;
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;
bool open(const QVariantHash &configuration) Q_DECL_OVERRIDE;
@@ -64,6 +65,7 @@ private:
void announceObjectAvailability(const QString &objectType, QObject *object, bool available);
QVector<QQmlDebugService *> m_services;
+ QVector<QJSEngine *> m_engines;
bool m_blockingMode;
};
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)