From 118f253a384bb98e970d209dc80ad698175c59a7 Mon Sep 17 00:00:00 2001 From: Lasse Holmstedt <lasse.holmstedt@nokia.com> Date: Mon, 2 Aug 2010 11:56:10 +0200 Subject: [PATCH] QML JS Debugger: Don't update deltas when not debugging --- src/plugins/qmljsinspector/qmljsinspector.cpp | 49 ++++++++++++------- src/plugins/qmljsinspector/qmljsinspector.h | 2 + 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index 0201deaddfd..5e0ca38bd2e 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -124,7 +124,8 @@ Inspector::Inspector(QObject *parent) m_connectionAttempts(0), m_cppDebuggerState(0), m_simultaneousCppAndQmlDebugMode(false), - m_debugMode(StandaloneMode) + m_debugMode(StandaloneMode), + m_listeningToEditorManager(false) { m_clientProxy = ClientProxy::instance(); @@ -160,11 +161,10 @@ void Inspector::disconnectWidgets() void Inspector::disconnected() { - Core::EditorManager *em = Core::EditorManager::instance(); - disconnect(em, SIGNAL(editorAboutToClose(Core::IEditor*)), this, SLOT(removePreviewForEditor(Core::IEditor*))); - disconnect(em, SIGNAL(editorOpened(Core::IEditor*)), this, SLOT(createPreviewForEditor(Core::IEditor*))); resetViews(); updateMenuActions(); + + applyChangesToQmlObserverHelper(false); } void Inspector::aboutToReloadEngines() @@ -227,15 +227,21 @@ void Inspector::initializeDocuments() if (!modelManager()) return; - m_loadedSnapshot = modelManager()->snapshot(); Core::EditorManager *em = Core::EditorManager::instance(); - connect(em, SIGNAL(editorAboutToClose(Core::IEditor*)), SLOT(removePreviewForEditor(Core::IEditor*))); - connect(em, SIGNAL(editorOpened(Core::IEditor*)), SLOT(createPreviewForEditor(Core::IEditor*))); + m_loadedSnapshot = modelManager()->snapshot(); + + if (!m_listeningToEditorManager) { + m_listeningToEditorManager = true; + connect(em, SIGNAL(editorAboutToClose(Core::IEditor*)), SLOT(removePreviewForEditor(Core::IEditor*))); + connect(em, SIGNAL(editorOpened(Core::IEditor*)), SLOT(createPreviewForEditor(Core::IEditor*))); + } // initial update foreach (Core::IEditor *editor, em->openedEditors()) { createPreviewForEditor(editor); } + + applyChangesToQmlObserverHelper(true); } void Inspector::serverReloaded() @@ -261,7 +267,9 @@ void Inspector::removePreviewForEditor(Core::IEditor *oldEditor) void Inspector::createPreviewForEditor(Core::IEditor *newEditor) { - if (newEditor && newEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) { + if (newEditor && newEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID + && m_clientProxy->isConnected()) + { QString filename = newEditor->file()->fileName(); QmlJS::Document::Ptr doc = modelManager()->snapshot().document(filename); if (!doc || !doc->qmlProgram()) @@ -643,16 +651,6 @@ bool Inspector::addQuotesForData(const QVariant &value) const return false; } -void Inspector::setApplyChangesToQmlObserver(bool applyChanges) -{ - emit livePreviewActivated(applyChanges); - QHashIterator<QString, QmlJSLiveTextPreview *> iter(m_textPreviews); - while(iter.hasNext()) { - iter.next(); - iter.value()->setApplyChangesToQmlObserver(applyChanges); - } -} - bool Inspector::showExperimentalWarning() { return m_showExperimentalWarning; @@ -663,6 +661,21 @@ void Inspector::setShowExperimentalWarning(bool value) m_showExperimentalWarning = value; } +void Inspector::setApplyChangesToQmlObserver(bool applyChanges) +{ + emit livePreviewActivated(applyChanges); + applyChangesToQmlObserverHelper(applyChanges); +} + +void Inspector::applyChangesToQmlObserverHelper(bool applyChanges) +{ + QHashIterator<QString, QmlJSLiveTextPreview *> iter(m_textPreviews); + while(iter.hasNext()) { + iter.next(); + iter.value()->setApplyChangesToQmlObserver(applyChanges); + } +} + void Inspector::disableLivePreview() { setApplyChangesToQmlObserver(false); diff --git a/src/plugins/qmljsinspector/qmljsinspector.h b/src/plugins/qmljsinspector/qmljsinspector.h index fb83678b3cf..971aa6fb1a0 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.h +++ b/src/plugins/qmljsinspector/qmljsinspector.h @@ -147,6 +147,7 @@ private: QmlJS::ModelManagerInterface *modelManager(); void initializeDocuments(); + void applyChangesToQmlObserverHelper(bool applyChanges); private: QWeakPointer<QDeclarativeEngineDebug> m_client; @@ -161,6 +162,7 @@ private: ClientProxy *m_clientProxy; static bool m_showExperimentalWarning; + bool m_listeningToEditorManager; // Qml/JS integration QHash<QString, QmlJSLiveTextPreview *> m_textPreviews; -- GitLab