From b794e982335a9b9dbb986900ca44c84d40da2566 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 24 Apr 2023 07:37:49 +0200 Subject: [PATCH] QMLLS: fix crash on opening non existing qml files The automatic handling of the document inside the language client manager is normally done after a document was opened successfully. Since the QML document registers the document manually on construction before the file was tried to be opened the automatic cleanup inside the manager does not work. Postpone the document registration like in the PythonDocument after the document was opened successfully. Fixes: QTCREATORBUG-29021 Change-Id: I2dd9e2da9c9ed6d38414ad991df3c03b62e9d611 Reviewed-by: Eike Ziller --- src/plugins/qmljseditor/qmljseditordocument.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 0575e2dbbba..a5b7687a2ac 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -505,7 +505,6 @@ QmlJSEditorDocumentPrivate::QmlJSEditorDocumentPrivate(QmlJSEditorDocument *pare this, &QmlJSEditorDocumentPrivate::updateOutlineModel); modelManager->updateSourceFiles(Utils::FilePaths({parent->filePath()}), false); - settingsChanged(); } QmlJSEditorDocumentPrivate::~QmlJSEditorDocumentPrivate() @@ -818,6 +817,8 @@ QmlJSEditorDocument::QmlJSEditorDocument(Utils::Id id) setId(id); connect(this, &TextEditor::TextDocument::tabSettingsChanged, d, &Internal::QmlJSEditorDocumentPrivate::invalidateFormatterCache); + connect(this, &TextEditor::TextDocument::openFinishedSuccessfully, + d, &Internal::QmlJSEditorDocumentPrivate::settingsChanged); setSyntaxHighlighter(new QmlJSHighlighter(document())); setCodec(QTextCodec::codecForName("UTF-8")); // qml files are defined to be utf-8 setIndenter(new Internal::Indenter(document()));