From 9a041e28ec478791240f2cbe8c19a9f3f8bc7a1a Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 12 Jun 2009 19:37:42 +0200 Subject: progress --- examples/debugger/main.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'examples/debugger/main.cpp') diff --git a/examples/debugger/main.cpp b/examples/debugger/main.cpp index 3c19ada..74f0e9e 100644 --- a/examples/debugger/main.cpp +++ b/examples/debugger/main.cpp @@ -26,6 +26,46 @@ void qScriptDebugRegisterMetaTypes(); +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(const QHostAddress &addr, quint16 port, bool listen, QObject *parent = 0); +private slots: + void onAttached(); + void onDetached(); +private: + QScriptRemoteTargetDebugger *m_debugger; +}; + +MyObject::MyObject(const QHostAddress &addr, quint16 port, bool listen, QObject *parent) + : QObject(parent) +{ + m_debugger = new QScriptRemoteTargetDebugger(this); + QObject::connect(m_debugger, SIGNAL(attached()), this, SLOT(onAttached())); + QObject::connect(m_debugger, SIGNAL(detached()), this, SLOT(onDetached())); + if (listen) { + if (m_debugger->listen(addr, port)) + qDebug("listening for debuggee connection at %s:%d", qPrintable(addr.toString()), port); + else { + qWarning("Failed to listen!"); + QCoreApplication::quit(); + } + } else { + qDebug("attaching to %s:%d", qPrintable(addr.toString()), port); + m_debugger->attachTo(addr, port); + } +} + +void MyObject::onAttached() +{ +} + +void MyObject::onDetached() +{ + QApplication::quit(); +} + int main(int argc, char **argv) { QApplication app(argc, argv); @@ -60,9 +100,8 @@ int main(int argc, char **argv) } qScriptDebugRegisterMetaTypes(); - QScriptRemoteTargetDebugger debugger; - qDebug("attaching to %s:%d", qPrintable(addr.toString()), port); - debugger.attachTo(addr, port); - + MyObject object(addr, port, listen); return app.exec(); } + +#include "main.moc" -- cgit v1.2.3