Commit f5f51b62 authored by Aurindam Jana's avatar Aurindam Jana

InspectorPlugin: Handle disconnect

Disonnect inspector when qml adapter emits disconnected
signal.

Change-Id: I2f9acbe2cc19c44edf500e7329d1590b73f97113
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@nokia.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 9e56781b
......@@ -349,6 +349,7 @@ void InspectorUi::disconnected()
m_clientProxy = 0;
m_propertyInspector->clear();
m_pendingPreviewDocumentNames.clear();
setDebuggerEngine(0);
}
void InspectorUi::objectTreeReady()
......
......@@ -101,7 +101,6 @@ void InspectorPlugin::extensionsInitialized()
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
connect(pluginManager, SIGNAL(objectAdded(QObject*)), SLOT(objectAdded(QObject*)));
connect(pluginManager, SIGNAL(aboutToRemoveObject(QObject*)), SLOT(aboutToRemoveObject(QObject*)));
connect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
this, SLOT(modeAboutToChange(Core::IMode*)));
}
......@@ -110,6 +109,8 @@ void InspectorPlugin::objectAdded(QObject *object)
{
Debugger::QmlAdapter *adapter = qobject_cast<Debugger::QmlAdapter *>(object);
if (adapter) {
//Disconnect inspector plugin when qml adapter emits disconnected
connect(adapter, SIGNAL(disconnected()), this, SLOT(disconnect()));
m_clientProxy = new ClientProxy(adapter);
if (m_clientProxy->isConnected()) {
clientProxyConnected();
......@@ -123,18 +124,13 @@ void InspectorPlugin::objectAdded(QObject *object)
m_inspectorUi->setDebuggerEngine(object);
}
void InspectorPlugin::aboutToRemoveObject(QObject *obj)
void InspectorPlugin::disconnect()
{
if (m_clientProxy && m_clientProxy->qmlAdapter() == obj) {
if (m_inspectorUi->isConnected())
m_inspectorUi->disconnected();
if (m_inspectorUi->isConnected()) {
m_inspectorUi->disconnected();
delete m_clientProxy;
m_clientProxy = 0;
}
if (m_inspectorUi->debuggerEngine() == obj) {
m_inspectorUi->setDebuggerEngine(0);
}
}
void InspectorPlugin::clientProxyConnected()
......@@ -150,7 +146,7 @@ void InspectorPlugin::modeAboutToChange(Core::IMode *newMode)
m_inspectorUi->setupUi();
// Make sure we're not called again.
disconnect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
QObject::disconnect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
this, SLOT(modeAboutToChange(Core::IMode*)));
}
}
......
......@@ -69,7 +69,7 @@ public:
private slots:
void objectAdded(QObject *object);
void aboutToRemoveObject(QObject *obj);
void disconnect();
void clientProxyConnected();
void modeAboutToChange(Core::IMode *mode);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment