summaryrefslogtreecommitdiffstats
path: root/examples
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
parentcd02187bf2fa3edf8c29fe73c244ff853a51f6ec (diff)
progress
Diffstat (limited to 'examples')
-rw-r--r--examples/debuggee/main.cpp16
-rw-r--r--examples/debugger/main.cpp47
2 files changed, 53 insertions, 10 deletions
diff --git a/examples/debuggee/main.cpp b/examples/debuggee/main.cpp
index fb9875a..ee024ef 100644
--- a/examples/debuggee/main.cpp
+++ b/examples/debuggee/main.cpp
@@ -22,14 +22,16 @@
#include <QtScript>
#include <qscriptdebuggerconnector.h>
+void qScriptDebugRegisterMetaTypes();
+
class MyObject : public QObject
{
Q_OBJECT
public:
MyObject(const QHostAddress &addr, quint16 port, bool connect, QObject *parent = 0);
private slots:
- void connected();
- void disconnected();
+ void onConnected();
+ void onDisconnected();
private:
QScriptEngine *m_engine;
QScriptDebuggerConnector *m_connector;
@@ -40,8 +42,8 @@ MyObject::MyObject(const QHostAddress &addr, quint16 port, bool connect, QObject
{
m_engine = new QScriptEngine(this);
m_connector = new QScriptDebuggerConnector(this);
- QObject::connect(m_connector, SIGNAL(connected()), this, SLOT(connected()), Qt::QueuedConnection);
- QObject::connect(m_connector, SIGNAL(disconnected()), this, SLOT(disconnected()), Qt::QueuedConnection);
+ QObject::connect(m_connector, SIGNAL(connected()), this, SLOT(onConnected()), Qt::QueuedConnection);
+ QObject::connect(m_connector, SIGNAL(disconnected()), this, SLOT(onDisconnected()), Qt::QueuedConnection);
m_connector->setEngine(m_engine);
if (connect) {
qDebug("attempting to connect to debugger at %s:%d", qPrintable(addr.toString()), port);
@@ -56,7 +58,7 @@ MyObject::MyObject(const QHostAddress &addr, quint16 port, bool connect, QObject
}
}
-void MyObject::connected()
+void MyObject::onConnected()
{
qDebug("connected!!");
QStringList fileNames;
@@ -75,7 +77,7 @@ void MyObject::connected()
m_connector->disconnectFromDebugger();
}
-void MyObject::disconnected()
+void MyObject::onDisconnected()
{
qDebug("disconnected");
QCoreApplication::quit();
@@ -112,6 +114,8 @@ int main(int argc, char **argv)
}
}
}
+
+ qScriptDebugRegisterMetaTypes();
MyObject obj(addr, port, connect);
return app.exec();
}
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"