From e9e6be0de1e1691b9d10cc9524aabf5d493858d6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 24 Aug 2010 14:23:40 +0200 Subject: QDeclarativeEngineDebugServer: make it a singleton. It is already a singleton, just formalize it so it can be used in other files than qdeclarativeengine.cpp This also remove the global olbject QDeclarativeEngineDebugServer::m_engines Reviewed-by: Lasse Holmstedt --- src/declarative/qml/qdeclarativeengine.cpp | 7 ++----- src/declarative/qml/qdeclarativeenginedebug.cpp | 8 +++++++- src/declarative/qml/qdeclarativeenginedebug_p.h | 8 +++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 4e45636..c5a5c18 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -438,8 +438,6 @@ void QDeclarativeEnginePrivate::clear(SimpleList &pss) pss.clear(); } -Q_GLOBAL_STATIC(QDeclarativeEngineDebugServer, qmlEngineDebugServer); - void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o) { QObjectPrivate *p = QObjectPrivate::get(o); @@ -481,9 +479,8 @@ void QDeclarativeEnginePrivate::init() if (QCoreApplication::instance()->thread() == q->thread() && QDeclarativeEngineDebugServer::isDebuggingEnabled()) { - qmlEngineDebugServer(); isDebugging = true; - QDeclarativeEngineDebugServer::addEngine(q); + QDeclarativeEngineDebugServer::instance()->addEngine(q); } } @@ -547,7 +544,7 @@ QDeclarativeEngine::~QDeclarativeEngine() { Q_D(QDeclarativeEngine); if (d->isDebugging) - QDeclarativeEngineDebugServer::remEngine(this); + QDeclarativeEngineDebugServer::instance()->remEngine(this); } /*! \fn void QDeclarativeEngine::quit() diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 688e0fc..056d8a0 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -58,7 +58,13 @@ QT_BEGIN_NAMESPACE -QList QDeclarativeEngineDebugServer::m_engines; +Q_GLOBAL_STATIC(QDeclarativeEngineDebugServer, qmlEngineDebugServer); + +QDeclarativeEngineDebugServer *QDeclarativeEngineDebugServer::instance() +{ + return qmlEngineDebugServer(); +} + QDeclarativeEngineDebugServer::QDeclarativeEngineDebugServer(QObject *parent) : QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), parent), m_watch(new QDeclarativeWatcher(this)) diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h index aa450f3..4704393 100644 --- a/src/declarative/qml/qdeclarativeenginedebug_p.h +++ b/src/declarative/qml/qdeclarativeenginedebug_p.h @@ -92,8 +92,10 @@ public: bool hasNotifySignal; }; - static void addEngine(QDeclarativeEngine *); - static void remEngine(QDeclarativeEngine *); + void addEngine(QDeclarativeEngine *); + void remEngine(QDeclarativeEngine *); + + static QDeclarativeEngineDebugServer *instance(); protected: virtual void messageReceived(const QByteArray &); @@ -111,7 +113,7 @@ private: void resetBinding(int objectId, const QString &propertyName); void setMethodBody(int objectId, const QString &method, const QString &body); - static QList m_engines; + QList m_engines; QDeclarativeWatcher *m_watch; }; Q_DECLARATIVE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectData &); -- cgit v0.12