diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-02-15 07:22:29 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-02-15 07:22:29 (GMT) |
commit | af36be2c7257870e1ad094ec7b2cc37ae4ca2176 (patch) | |
tree | 5e69a670cad06f62f8a5b539105995cea00ae0aa /src/declarative/debugger | |
parent | b258be1d39889e65411324fe5cda47a34f814033 (diff) | |
download | Qt-af36be2c7257870e1ad094ec7b2cc37ae4ca2176.zip Qt-af36be2c7257870e1ad094ec7b2cc37ae4ca2176.tar.gz Qt-af36be2c7257870e1ad094ec7b2cc37ae4ca2176.tar.bz2 |
For qmldebug* tests, make sure engine is running before the test thread
is started. Also fix some memory leaks.
Diffstat (limited to 'src/declarative/debugger')
-rw-r--r-- | src/declarative/debugger/qmldebugservice.cpp | 33 | ||||
-rw-r--r-- | src/declarative/debugger/qmldebugservice_p.h | 4 |
2 files changed, 36 insertions, 1 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); diff --git a/src/declarative/debugger/qmldebugservice_p.h b/src/declarative/debugger/qmldebugservice_p.h index b406a3c..ec90d95 100644 --- a/src/declarative/debugger/qmldebugservice_p.h +++ b/src/declarative/debugger/qmldebugservice_p.h @@ -68,17 +68,19 @@ public: static int idForObject(QObject *); static QObject *objectForId(int); - static bool isDebuggingEnabled(); static QString objectToString(QObject *obj); static void waitForClients(); + static void notifyOnServerStart(QObject *object, const char *receiver); + protected: virtual void enabledChanged(bool); virtual void messageReceived(const QByteArray &); private: + void registerForStartNotification(QObject *object, const char *methodName); friend class QmlDebugServer; }; |