From 28590651935ac59d687037a9581d1c21b88721fd Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Thu, 12 Aug 2010 09:46:22 +0200 Subject: [PATCH] qmljsinspector: movve debugger related code around --- .../qmljsinspector/qmljsclientproxy.cpp | 40 ++++++++++++++++++- src/plugins/qmljsinspector/qmljsclientproxy.h | 1 + .../qmljsinspector/qmljsdebuggerclient.cpp | 22 +--------- .../qmljsinspector/qmljsdebuggerclient.h | 10 ++--- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp index 3e2836f3d7a..7d419d55b18 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp +++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp @@ -26,11 +26,16 @@ ** contact the sales department at http://qt.nokia.com/contact. ** **************************************************************************/ + #include "qmljsclientproxy.h" #include "qmljsdebuggerclient.h" #include "qmljsprivateapi.h" #include "qmljsdesigndebugclient.h" +#include <debugger/debuggerplugin.h> +#include <debugger/debuggerrunner.h> +#include <debugger/qml/qmlengine.h> +#include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> #include <QUrl> @@ -240,8 +245,7 @@ void ClientProxy::connectionStateChanged() SLOT(refreshObjectTree())); } - (void) new DebuggerClient(m_conn); - + createDebuggerClient(); reloadEngines(); break; @@ -255,6 +259,38 @@ void ClientProxy::connectionStateChanged() } } +void ClientProxy::createDebuggerClient() +{ + DebuggerClient *debuggerClient = new DebuggerClient(m_conn); + 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); + Debugger::Internal::QmlEngine *engine = + qobject_cast<Debugger::Internal::QmlEngine *>(debuggerRunControl->engine()); + QTC_ASSERT(engine, return); + + engine->Debugger::Internal::DebuggerEngine::startDebugger(debuggerRunControl); + + connect(engine, SIGNAL(sendMessage(QByteArray)), + debuggerClient, SLOT(slotSendMessage(QByteArray))); + connect(debuggerClient, SIGNAL(messageWasReceived(QByteArray)), + engine, SLOT(messageReceived(QByteArray))); + connect(m_conn, SIGNAL(disconnected()), + engine, SLOT(disconnected())); + + //engine->startSuccessful(); // FIXME: AAA: port to new debugger states +} + bool ClientProxy::isConnected() const { return m_conn && m_client && m_conn->state() == QAbstractSocket::ConnectedState; diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.h b/src/plugins/qmljsinspector/qmljsclientproxy.h index 95264f27bfe..04f1bb6a5fa 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.h +++ b/src/plugins/qmljsinspector/qmljsclientproxy.h @@ -123,6 +123,7 @@ private slots: private: bool isDesignClientConnected() const; void reloadEngines(); + void createDebuggerClient(); QList<QDeclarativeDebugObjectReference> objectReferences(const QUrl &url, const QDeclarativeDebugObjectReference &objectRef) const; QDeclarativeDebugObjectReference objectReferenceForId(int debugId, const QDeclarativeDebugObjectReference &ref) const; diff --git a/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp b/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp index 36dac9a7a31..27450482660 100644 --- a/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp +++ b/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp @@ -35,27 +35,7 @@ using namespace QmlJSInspector::Internal; DebuggerClient::DebuggerClient(QDeclarativeDebugConnection* client) : QDeclarativeDebugClient(QLatin1String("JSDebugger"), client) - , 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(); // FIXME: AAA: port to new debugger states - - connect(engine, SIGNAL(sendMessage(QByteArray)), this, SLOT(slotSendMessage(QByteArray))); - connect(connection, SIGNAL(disconnected()), engine, SLOT(disconnected())); setEnabled(true); } @@ -65,7 +45,7 @@ DebuggerClient::~DebuggerClient() void DebuggerClient::messageReceived(const QByteArray &data) { - engine->messageReceived(data); + emit messageWasReceived(data); } void DebuggerClient::slotSendMessage(const QByteArray &message) diff --git a/src/plugins/qmljsinspector/qmljsdebuggerclient.h b/src/plugins/qmljsinspector/qmljsdebuggerclient.h index cfdaead5f96..4daf16fe6e4 100644 --- a/src/plugins/qmljsinspector/qmljsdebuggerclient.h +++ b/src/plugins/qmljsinspector/qmljsdebuggerclient.h @@ -26,14 +26,11 @@ ** contact the sales department at http://qt.nokia.com/contact. ** **************************************************************************/ + #ifndef QMLJSDEBUGGERCLIENT_H #define QMLJSDEBUGGERCLIENT_H #include "qmljsprivateapi.h" -#include <debugger/qml/qmlengine.h> -#include <debugger/stackframe.h> -#include <debugger/stackhandler.h> -#include <debugger/debuggerrunner.h> namespace QmlJSInspector { namespace Internal { @@ -46,9 +43,8 @@ public: DebuggerClient(QDeclarativeDebugConnection *client); virtual ~DebuggerClient(); -public: // attributes - QDeclarativeDebugConnection *connection; - Debugger::Internal::QmlEngine *engine; +signals: + void messageWasReceived(const QByteArray &data); private Q_SLOTS: void slotSendMessage(const QByteArray &message); -- GitLab