From ea6775d10461db226ed5b79b1e53416250087a39 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <olivier.goffart@nokia.com>
Date: Fri, 2 Jul 2010 11:58:10 +0200
Subject: [PATCH] QmlJSInspector::ClientProxy:  make the QML - JS debugger
 actually work

---
 .../qmljsinspector/qmljsclientproxy.cpp       | 26 ++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp
index bfbd0d1edc2..35105778808 100644
--- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp
+++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp
@@ -31,6 +31,7 @@
 #include "qmljsprivateapi.h"
 
 #include <utils/qtcassert.h>
+#include <extensionsystem/pluginmanager.h>
 
 #include <QUrl>
 #include <QAbstractSocket>
@@ -97,12 +98,6 @@ bool ClientProxy::connectToViewer(const QString &host, quint16 port)
     if (!m_conn->waitForConnected())
         return false;
 
-//  ### commented out as the code resulted in asserts
-//    QTC_ASSERT(m_debuggerRunControl, return false);
-//    Debugger::Internal::QmlEngine *engine = qobject_cast<Debugger::Internal::QmlEngine *>(m_debuggerRunControl->engine());
-//    QTC_ASSERT(engine, return false);
-//    (void) new DebuggerClient(m_conn, engine);
-
     return true;
 }
 
@@ -162,6 +157,25 @@ 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();
+            }
+
             reloadEngines();
 
             break;
-- 
GitLab