summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-16 16:17:17 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-08-04 13:35:18 +0000
commit275ddd68af1881c5712848a4be9892f84b62b321 (patch)
treedf846963158857e8b84a66f2d6e64f2528f0363e /src/plugins
parent20d06b5e822cc301e31f77a87915eed62195eb92 (diff)
downloadqtdeclarative-275ddd68af1881c5712848a4be9892f84b62b321.tar.gz
qtdeclarative-275ddd68af1881c5712848a4be9892f84b62b321.tar.bz2
qtdeclarative-275ddd68af1881c5712848a4be9892f84b62b321.zip
Clean up QQmlDebugConnector's addService() and removeService()
As we look up services by name we should also add and remove them by name. As the thread doesn't run during adding and removing of services we don't have to check the client plugins for the initial state. It's also a good idea to eventually disconnect any signals that we connect on addService(). Change-Id: I9acd17d2caafe15831f32b7b959dc2dea9cab08c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index 91982b415..1459ab875 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -94,8 +94,8 @@ public:
void addEngine(QQmlEngine *engine);
void removeEngine(QQmlEngine *engine);
- bool addService(QQmlDebugService *service);
- bool removeService(QQmlDebugService *service);
+ bool addService(const QString &name, QQmlDebugService *service);
+ bool removeService(const QString &name);
bool open(const QVariantHash &configuration);
void setDevice(QIODevice *socket);
@@ -601,11 +601,14 @@ void QQmlDebugServerImpl::removeEngine(QQmlEngine *engine)
service->engineRemoved(engine);
}
-bool QQmlDebugServerImpl::addService(QQmlDebugService *service)
+bool QQmlDebugServerImpl::addService(const QString &name, QQmlDebugService *service)
{
// to be executed before thread starts
Q_ASSERT(!m_thread);
+ if (!service || m_plugins.contains(name))
+ return false;
+
connect(service, SIGNAL(messageToClient(QString,QByteArray)),
this, SLOT(sendMessage(QString,QByteArray)));
connect(service, SIGNAL(messagesToClient(QString,QList<QByteArray>)),
@@ -616,31 +619,28 @@ bool QQmlDebugServerImpl::addService(QQmlDebugService *service)
connect(service, SIGNAL(detachedFromEngine(QQmlEngine*)),
this, SLOT(wakeEngine(QQmlEngine*)), Qt::QueuedConnection);
+ service->setState(QQmlDebugService::Unavailable);
+ m_plugins.insert(name, service);
- if (!service || m_plugins.contains(service->name()))
- return false;
- m_plugins.insert(service->name(), service);
- QQmlDebugService::State newState = QQmlDebugService::Unavailable;
- if (m_clientPlugins.contains(service->name()))
- newState = QQmlDebugService::Enabled;
- service->setState(newState);
return true;
}
-bool QQmlDebugServerImpl::removeService(QQmlDebugService *service)
+bool QQmlDebugServerImpl::removeService(const QString &name)
{
// to be executed after thread ends
Q_ASSERT(!m_thread);
- QQmlDebugService::State newState = QQmlDebugService::NotConnected;
+ QQmlDebugService *service = m_plugins.value(name);
+ if (!service)
+ return false;
- m_changeServiceStateCalls.ref();
- QMetaObject::invokeMethod(this, "changeServiceState", Qt::QueuedConnection,
- Q_ARG(QString, service->name()),
- Q_ARG(QQmlDebugService::State, newState));
+ m_plugins.remove(name);
+ service->setState(QQmlDebugService::NotConnected);
- if (!service || !m_plugins.contains(service->name()))
- return false;
+ disconnect(service, SIGNAL(detachedFromEngine(QQmlEngine*)),
+ this, SLOT(wakeEngine(QQmlEngine*)));
+ disconnect(service, SIGNAL(attachedToEngine(QQmlEngine*)),
+ this, SLOT(wakeEngine(QQmlEngine*)));
disconnect(service, SIGNAL(messagesToClient(QString,QList<QByteArray>)),
this, SLOT(sendMessages(QString,QList<QByteArray>)));