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
This commit is contained in:
Kai Koehne
2010-10-25 14:27:39 +02:00
parent 7e50ebcfba
commit c33348a49f
2 changed files with 16 additions and 0 deletions

View File

@@ -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();

View File

@@ -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;