diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-02-16 00:05:25 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-02-16 00:05:25 (GMT) |
commit | 5cef28d2fe4a6ac814b30cbd03a259fa9e371008 (patch) | |
tree | 2f1ac0d92439c593f6fccdb42d294ecda091ea4f /src/declarative/debugger/qmldebugservice.cpp | |
parent | 89505af1661fab0c12585416b66322cd09a30bdf (diff) | |
parent | 0c0cde558139d12531c4b1e820622bcb81b8eaa5 (diff) | |
download | Qt-5cef28d2fe4a6ac814b30cbd03a259fa9e371008.zip Qt-5cef28d2fe4a6ac814b30cbd03a259fa9e371008.tar.gz Qt-5cef28d2fe4a6ac814b30cbd03a259fa9e371008.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'src/declarative/debugger/qmldebugservice.cpp')
-rw-r--r-- | src/declarative/debugger/qmldebugservice.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/declarative/debugger/qmldebugservice.cpp b/src/declarative/debugger/qmldebugservice.cpp index 810fbed..2c9586f 100644 --- a/src/declarative/debugger/qmldebugservice.cpp +++ b/src/declarative/debugger/qmldebugservice.cpp @@ -61,9 +61,11 @@ class QmlDebugServer : public QObject public: static QmlDebugServer *instance(); void wait(); + void registerForStartNotification(QObject *object, const char *receiver); private Q_SLOTS: void readyRead(); + void registeredObjectDestroyed(QObject *object); private: friend class QmlDebugService; @@ -83,6 +85,7 @@ public: QPacketProtocol *protocol; QHash<QString, QmlDebugService *> plugins; QStringList enabledPlugins; + QList<QPair<QObject*, QByteArray> > notifyClients; }; class QmlDebugServicePrivate : public QObjectPrivate @@ -112,6 +115,14 @@ void QmlDebugServerPrivate::wait() qWarning("QmlDebugServer: Waiting for connection on port %d...", port); + for (int i=0; i<notifyClients.count(); i++) { + if (!QMetaObject::invokeMethod(notifyClients[i].first, notifyClients[i].second)) { + qWarning() << "QmlDebugServer: unable to call method" << notifyClients[i].second + << "on object" << notifyClients[i].first << "to notify of debug server start"; + } + } + notifyClients.clear(); + if (!server.waitForNewConnection(-1)) { qWarning("QmlDebugServer: Connection error"); return; @@ -165,6 +176,23 @@ void QmlDebugServer::wait() d->wait(); } +void QmlDebugServer::registerForStartNotification(QObject *object, const char *methodName) +{ + Q_D(QmlDebugServer); + connect(object, SIGNAL(destroyed(QObject*)), SLOT(registeredObjectDestroyed(QObject*))); + d->notifyClients.append(qMakePair(object, QByteArray(methodName))); +} + +void QmlDebugServer::registeredObjectDestroyed(QObject *object) +{ + Q_D(QmlDebugServer); + QMutableListIterator<QPair<QObject*, QByteArray> > i(d->notifyClients); + while (i.hasNext()) { + if (i.next().first == object) + i.remove(); + } +} + QmlDebugServer::QmlDebugServer(int port) : QObject(*(new QmlDebugServerPrivate)) { @@ -367,6 +395,11 @@ void QmlDebugService::waitForClients() QmlDebugServer::instance()->wait(); } +void QmlDebugService::notifyOnServerStart(QObject *object, const char *receiver) +{ + QmlDebugServer::instance()->registerForStartNotification(object, receiver); +} + void QmlDebugService::sendMessage(const QByteArray &message) { Q_D(QmlDebugService); |