summaryrefslogtreecommitdiffstats
path: root/examples/debugger/main.cpp
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-12 19:37:42 +0200
committerKent Hansen <khansen@trolltech.com>2009-06-12 19:37:42 +0200
commit9a041e28ec478791240f2cbe8c19a9f3f8bc7a1a (patch)
tree9f9556753fb1c6f3080b9df8aecceeb2e4e039f3 /examples/debugger/main.cpp
parentcd02187bf2fa3edf8c29fe73c244ff853a51f6ec (diff)
progress
Diffstat (limited to 'examples/debugger/main.cpp')
-rw-r--r--examples/debugger/main.cpp47
1 files changed, 43 insertions, 4 deletions
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"