From c33348a49fa24cdd22dd0c0957e9712c799f3d17 Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@nokia.com> Date: Mon, 25 Oct 2010 14:27:39 +0200 Subject: [PATCH] Observer mode: Fix automatic selection of all instances If the user clicks on an instance of an element in the running app while in server mode, the cursor selection is automatically updated. However, the change of the cursor then leads to all the other instances of the element at the cursor position being selected too. Prevent this 'call back' in the QmlInspector by checking whether one of the newly selected items is the one just selected. Simpler mechanisms (like a sequential blocking of updates) don't work because the call back happens through a QTimer. Task-number: QTCREATORBUG-2366 --- src/plugins/qmljsinspector/qmljsinspector.cpp | 15 +++++++++++++++ src/plugins/qmljsinspector/qmljsinspector.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index 174ca43872e..6798e46327a 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -138,6 +138,7 @@ InspectorUi::InspectorUi(QObject *parent) , m_clientProxy(0) , m_qmlEngine(0) , m_debugQuery(0) + , m_lastSelectedDebugId(-1) , m_debugProject(0) { m_instance = this; @@ -350,6 +351,18 @@ void InspectorUi::updateEngineList() void InspectorUi::changeSelectedItems(const QList<QDeclarativeDebugObjectReference> &objects) { + if (m_lastSelectedDebugId >= 0) { + foreach (QDeclarativeDebugObjectReference ref, objects) { + if (ref.debugId() == m_lastSelectedDebugId) { + // this is only the 'call back' after we have programatically set a new cursor + // position in + m_lastSelectedDebugId = -1; + return; + } + } + m_lastSelectedDebugId = -1; + } + m_clientProxy->setSelectedItemsByObjectId(objects); } @@ -548,6 +561,8 @@ void InspectorUi::gotoObjectReferenceDefinition(const QDeclarativeDebugObjectRef TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor); if (textEditor) { + m_lastSelectedDebugId = obj.debugId(); + editorManager->addCurrentPositionToNavigationHistory(); textEditor->gotoLine(source.lineNumber()); textEditor->widget()->setFocus(); diff --git a/src/plugins/qmljsinspector/qmljsinspector.h b/src/plugins/qmljsinspector/qmljsinspector.h index d290a27b4ee..99d6bfafe8f 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.h +++ b/src/plugins/qmljsinspector/qmljsinspector.h @@ -162,6 +162,7 @@ private: ClientProxy *m_clientProxy; Debugger::QmlEngine *m_qmlEngine; QDeclarativeDebugExpressionQuery *m_debugQuery; + int m_lastSelectedDebugId; // Qml/JS integration QHash<QString, QmlJSLiveTextPreview *> m_textPreviews; -- GitLab