diff --git a/src/plugins/qmldesigner/components/texteditor/texteditorview.cpp b/src/plugins/qmldesigner/components/texteditor/texteditorview.cpp index 6c6102036ac..0826df54848 100644 --- a/src/plugins/qmldesigner/components/texteditor/texteditorview.cpp +++ b/src/plugins/qmldesigner/components/texteditor/texteditorview.cpp @@ -16,12 +16,13 @@ #include #include -#include #include +#include #include #include #include #include +#include #include #include @@ -97,9 +98,12 @@ void TextEditorView::modelAboutToBeDetached(Model *model) m_widget->setTextEditor(nullptr); // 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); + if (Core::ModeManager::currentModeId() == Core::Constants::MODE_DESIGN) { + if (TextEditor::BaseTextEditor *textEditor = QmlDesignerPlugin::instance() + ->currentDesignDocument() + ->textEditor()) { + QmlDesignerPlugin::instance()->emitCurrentTextEditorChanged(textEditor); + } } }