Commit 28590651 authored by hjk's avatar hjk

qmljsinspector: movve debugger related code around

parent 4fb517c5
......@@ -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;
......
......@@ -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;
......
......@@ -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)
......
......@@ -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);
......
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