From ce134d37f75ce44bfd29fc0ffb5e2a191ffdf7f8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart <olivier.goffart@nokia.com> Date: Tue, 24 Aug 2010 15:24:04 +0200 Subject: [PATCH] QmlDebugger: use another way for detecting new objects --- .../qmljsdebugclient/qdeclarativedebug.cpp | 4 ++++ .../qmljsdebugclient/qdeclarativedebug_p.h | 3 +++ .../qmljsinspector/qmljsclientproxy.cpp | 18 +++++++++++++++--- src/plugins/qmljsinspector/qmljsclientproxy.h | 2 ++ .../qmljsinspector/qmljsdesigndebugclient.cpp | 2 +- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/libs/qmljsdebugclient/qdeclarativedebug.cpp b/src/libs/qmljsdebugclient/qdeclarativedebug.cpp index 3b36cad363c..064549aca60 100644 --- a/src/libs/qmljsdebugclient/qdeclarativedebug.cpp +++ b/src/libs/qmljsdebugclient/qdeclarativedebug.cpp @@ -66,6 +66,7 @@ public: void message(const QByteArray &); QDeclarativeEngineDebugClient *client; + QDeclarativeEngineDebug *q_ptr; int nextId; int getId(); @@ -371,12 +372,15 @@ void QDeclarativeEngineDebugPrivate::message(const QByteArray &data) if (!watch) return; emit watch->valueChanged(name, value); + } else if (type == "OBJECT_CREATED") { + emit q_ptr->newObjects(); } } QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent) : QObject(parent), d_ptr(new QDeclarativeEngineDebugPrivate(client)) { + d_ptr->q_ptr = this; } QDeclarativeEngineDebug::~QDeclarativeEngineDebug() {} diff --git a/src/libs/qmljsdebugclient/qdeclarativedebug_p.h b/src/libs/qmljsdebugclient/qdeclarativedebug_p.h index ffdbbb72168..ad616411b69 100644 --- a/src/libs/qmljsdebugclient/qdeclarativedebug_p.h +++ b/src/libs/qmljsdebugclient/qdeclarativedebug_p.h @@ -100,6 +100,9 @@ public: bool resetBindingForObject(int objectDebugId, const QString &propertyName); bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); +signals: + void newObjects(); + private: Q_DECLARE_PRIVATE(QDeclarativeEngineDebug) Q_DISABLE_COPY(QDeclarativeEngineDebug) diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp index f72996470de..6b5e2581168 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp +++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp @@ -52,8 +52,11 @@ ClientProxy::ClientProxy(Debugger::Internal::QmlAdapter *adapter, QObject *paren , m_engineQuery(0) , m_contextQuery(0) { - + m_requestObjectsTimer.setSingleShot(true); + m_requestObjectsTimer.setInterval(3000); connect(m_adapter, SIGNAL(aboutToDisconnect()), SLOT(disconnectFromServer())); + connect(m_client, SIGNAL(newObjects()), this, SLOT(newObjects())); + connect(&m_requestObjectsTimer, SIGNAL(timeout()), this, SLOT(refreshObjectTree())); connectToServer(); } @@ -82,8 +85,8 @@ void ClientProxy::connectToServer() SIGNAL(selectedColorChanged(QColor))); connect(m_designClient, SIGNAL(contextPathUpdated(QStringList)), SIGNAL(contextPathUpdated(QStringList))); - connect(m_designClient, SIGNAL(treeRefreshRequested()), - SLOT(refreshObjectTree())); + /* connect(m_designClient, SIGNAL(treeRefreshRequested()), + SLOT(refreshObjectTree()));*/ reloadEngines(); } @@ -131,6 +134,7 @@ void ClientProxy::disconnectFromServer() void ClientProxy::refreshObjectTree() { if (!m_contextQuery) { + m_requestObjectsTimer.stop(); qDeleteAll(m_objectTreeQuery); m_objectTreeQuery.clear(); queryEngineContext(m_engines.value(0).debugId()); @@ -286,6 +290,7 @@ void ClientProxy::contextChanged() qDeleteAll(m_objectTreeQuery); m_objectTreeQuery.clear(); + m_requestObjectsTimer.stop(); fetchContextObjectRecusrsive(rootContext); } @@ -443,3 +448,10 @@ bool ClientProxy::isConnected() const { return m_adapter->isConnected(); } + +void ClientProxy::newObjects() +{ + if (!m_requestObjectsTimer.isActive()) + m_requestObjectsTimer.start(); +} + diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.h b/src/plugins/qmljsinspector/qmljsclientproxy.h index fcc30eafb1f..f7e617971da 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.h +++ b/src/plugins/qmljsinspector/qmljsclientproxy.h @@ -125,6 +125,7 @@ private slots: void updateEngineList(); void objectTreeFetched(QDeclarativeDebugQuery::State state = QDeclarativeDebugQuery::Completed); void fetchContextObjectRecusrsive(const QmlJsDebugClient::QDeclarativeDebugContextReference& context); + void newObjects(); private: bool isDesignClientConnected() const; @@ -146,6 +147,7 @@ private: QList<QDeclarativeDebugObjectReference> m_rootObjects; QList<QDeclarativeDebugEngineReference> m_engines; + QTimer m_requestObjectsTimer; }; } // namespace Internal diff --git a/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp b/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp index c51bfcd31e4..2e2b2332cb3 100644 --- a/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp +++ b/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp @@ -109,7 +109,7 @@ void QmlJSDesignDebugClient::messageReceived(const QByteArray &message) ds >> contextPath; emit contextPathUpdated(contextPath); } else if (type == "SCENE_ITEM_COUNT_CHANGED") { - emit treeRefreshRequested(); + //emit treeRefreshRequested(); } } -- GitLab