QmlDesigner: reduce editor changed signals

- detaching the TextEditView already emits the TextEditor change signal
   -> so removing the call from QmlDesignerPlugin::deactivateAutoSynchronization()
 - in case the user closed explicit the editor we do not want to emit any
   signals anymore

Change-Id: Idb5c2cdde583f7d32f2a9ef5628d1b6d3fc7bb3f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Tim Jenssen
2017-10-17 17:43:53 +02:00
committed by Thomas Hartmann
parent b25d21f42e
commit 668c87ffd9
3 changed files with 13 additions and 2 deletions

View File

@@ -45,6 +45,7 @@
#include <qtsupport/qtsupportconstants.h>
#include <qtsupport/qtversionmanager.h>
#include <coreplugin/idocument.h>
#include <coreplugin/editormanager/editormanager.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
@@ -605,6 +606,13 @@ RewriterView *DesignDocument::rewriterView() const
void DesignDocument::setEditor(Core::IEditor *editor)
{
m_textEditor = editor;
// if the user closed the file explicit we do not want to do anything with it anymore
connect(Core::EditorManager::instance(), &Core::EditorManager::editorAboutToClose,
this, [this](Core::IEditor *editor) {
if (m_textEditor.data() == editor)
m_textEditor.clear();
});
connect(editor->document(), &Core::IDocument::filePathChanged,
this, &DesignDocument::updateFileName);

View File

@@ -118,7 +118,11 @@ void TextEditorView::modelAboutToBeDetached(Model *model)
m_widget->setTextEditor(0);
QmlDesignerPlugin::instance()->emitCurrentTextEditorChanged(QmlDesignerPlugin::instance()->currentDesignDocument()->textEditor());
// in case the user closed it explicit we do not want to do anything with the editor
if (TextEditor::BaseTextEditor *textEditor =
QmlDesignerPlugin::instance()->currentDesignDocument()->textEditor()) {
QmlDesignerPlugin::instance()->emitCurrentTextEditorChanged(textEditor);
}
}
void TextEditorView::importsChanged(const QList<Import> &/*addedImports*/, const QList<Import> &/*removedImports*/)

View File

@@ -413,7 +413,6 @@ void QmlDesignerPlugin::deactivateAutoSynchronization()
viewManager().detachViewsExceptRewriterAndComponetView();
viewManager().detachComponentView();
viewManager().detachRewriterView();
emitCurrentTextEditorChanged(documentManager().currentDesignDocument()->textEditor());
documentManager().currentDesignDocument()->resetToDocumentModel();
}