From cc5d0459dddeb47b033bc597cf8228b14ca067ff Mon Sep 17 00:00:00 2001
From: Olivier Goffart <olivier.goffart@nokia.com>
Date: Fri, 2 Jul 2010 12:31:34 +0200
Subject: [PATCH] QmlJSInspector::DebuggerClient: move the code around

---
 .../qmljsinspector/qmljsclientproxy.cpp       | 23 ++----------------
 src/plugins/qmljsinspector/qmljsclientproxy.h |  1 -
 .../qmljsinspector/qmljsdebuggerclient.cpp    | 24 +++++++++++++++++--
 .../qmljsinspector/qmljsdebuggerclient.h      |  2 +-
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp
index 35105778808..6138feaece6 100644
--- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp
+++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp
@@ -31,7 +31,6 @@
 #include "qmljsprivateapi.h"
 
 #include <utils/qtcassert.h>
-#include <extensionsystem/pluginmanager.h>
 
 #include <QUrl>
 #include <QAbstractSocket>
@@ -47,8 +46,7 @@ ClientProxy::ClientProxy(QObject *parent) :
     m_client(0),
     m_engineQuery(0),
     m_contextQuery(0),
-    m_objectTreeQuery(0),
-    m_debuggerRunControl(0)
+    m_objectTreeQuery(0)
 {
     Q_ASSERT(! m_instance);
     m_instance = this;
@@ -157,24 +155,7 @@ void ClientProxy::connectionStateChanged()
 #endif
             }
 
-            {
-                ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
-                const QList<Debugger::DebuggerRunControlFactory *> factories = pm->getObjects<Debugger::DebuggerRunControlFactory>();
-                ProjectExplorer::RunControl *runControl = 0;
-
-                Debugger::DebuggerStartParameters sp;
-                sp.startMode = Debugger::StartExternal;
-                sp.executable = "qmlviewer"; //FIXME
-                runControl = factories.first()->create(sp);
-                m_debuggerRunControl = qobject_cast<Debugger::DebuggerRunControl *>(runControl);
-
-                QTC_ASSERT(m_debuggerRunControl, return );
-                Debugger::Internal::QmlEngine *engine = qobject_cast<Debugger::Internal::QmlEngine *>(m_debuggerRunControl->engine());
-                QTC_ASSERT(engine, return );
-                (void) new DebuggerClient(m_conn, engine);
-                engine->Debugger::Internal::DebuggerEngine::startDebugger(m_debuggerRunControl);
-                engine->startSuccessful();
-            }
+            (void) new DebuggerClient(m_conn);
 
             reloadEngines();
 
diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.h b/src/plugins/qmljsinspector/qmljsclientproxy.h
index d212c262b59..4ba30cd25b7 100644
--- a/src/plugins/qmljsinspector/qmljsclientproxy.h
+++ b/src/plugins/qmljsinspector/qmljsclientproxy.h
@@ -117,7 +117,6 @@ private:
     QDeclarativeDebugObjectReference m_rootObject;
     QList<QDeclarativeDebugEngineReference> m_engines;
 
-    Debugger::DebuggerRunControl *m_debuggerRunControl;
     friend class QmlJSInspector::Internal::InspectorPlugin;
 };
 
diff --git a/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp b/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp
index 7458c23ab7d..1e10517b6ee 100644
--- a/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp
+++ b/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp
@@ -28,12 +28,32 @@
 **************************************************************************/
 #include "qmljsdebuggerclient.h"
 
+#include <extensionsystem/pluginmanager.h>
+#include <utils/qtcassert.h>
+
 using namespace QmlJSInspector::Internal;
 
-DebuggerClient::DebuggerClient(QDeclarativeDebugConnection *client, Debugger::Internal::QmlEngine *engine)
+DebuggerClient::DebuggerClient(QDeclarativeDebugConnection* client)
     : QDeclarativeDebugClient(QLatin1String("Debugger"), client)
-    , connection(client), engine(engine)
+    , connection(client)
 {
+    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+    const QList<Debugger::DebuggerRunControlFactory *> factories = pm->getObjects<Debugger::DebuggerRunControlFactory>();
+    ProjectExplorer::RunControl *runControl = 0;
+
+    Debugger::DebuggerStartParameters sp;
+    sp.startMode = Debugger::StartExternal;
+    sp.executable = "qmlviewer"; //FIXME
+    runControl = factories.first()->create(sp);
+    Debugger::DebuggerRunControl* debuggerRunControl = qobject_cast<Debugger::DebuggerRunControl *>(runControl);
+
+    QTC_ASSERT(debuggerRunControl, return );
+    engine = qobject_cast<Debugger::Internal::QmlEngine *>(debuggerRunControl->engine());
+    QTC_ASSERT(engine, return );
+
+    engine->Debugger::Internal::DebuggerEngine::startDebugger(debuggerRunControl);
+    engine->startSuccessful();
+
     connect(engine, SIGNAL(sendMessage(QByteArray)), this, SLOT(slotSendMessage(QByteArray)));
     setEnabled(true);
 }
diff --git a/src/plugins/qmljsinspector/qmljsdebuggerclient.h b/src/plugins/qmljsinspector/qmljsdebuggerclient.h
index 8bf8ac589b7..cfdaead5f96 100644
--- a/src/plugins/qmljsinspector/qmljsdebuggerclient.h
+++ b/src/plugins/qmljsinspector/qmljsdebuggerclient.h
@@ -43,7 +43,7 @@ class DebuggerClient : public QDeclarativeDebugClient
     Q_OBJECT
 
 public:
-    DebuggerClient(QDeclarativeDebugConnection *client, Debugger::Internal::QmlEngine *engine);
+    DebuggerClient(QDeclarativeDebugConnection *client);
     virtual ~DebuggerClient();
 
 public: // attributes
-- 
GitLab