From 04fc1fcbce3833d38128403f15bbbdee3ab60307 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 11 Dec 2024 15:44:51 +0100 Subject: [PATCH] qmlls client: avoid creating clients for an empty qmlls path This is plain wrong and may result in unwanted side effects down the line. Change-Id: Ibe6f1fc31788a9994f4d9d0ff130fc88dc4422aa Reviewed-by: Sami Shalayel --- src/plugins/qmljseditor/qmljseditordocument.cpp | 6 ++---- src/plugins/qmljseditor/qmllsclient.cpp | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 1bec169fe1e..de977d9cff1 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -765,7 +765,7 @@ void QmlJSEditorDocumentPrivate::settingsChanged() return; FilePath newQmlls = qmllsForFile(q->filePath(), ModelManagerInterface::instance()); - if (m_qmllsStatus.qmllsPath == newQmlls) { + if (!newQmlls.isEmpty() && m_qmllsStatus.qmllsPath == newQmlls) { if (QmllsClient *client = QmllsClient::clientForQmlls(newQmlls)) { client->updateQmllsSemanticHighlightingCapability(); setSourcesWithCapabilities(client->capabilities()); @@ -781,9 +781,7 @@ void QmlJSEditorDocumentPrivate::settingsChanged() if (LanguageClientManager::clientForDocument(q) != nullptr) { qCDebug(qmllsLog) << "deactivating " << q->filePath() << "in qmlls" << newQmlls; LanguageClientManager::openDocumentWithClient(q, nullptr); - } else - qCWarning(qmllsLog) << "Could not find client to disable for document " << q->filePath() - << " in LanguageClient::LanguageClientManager"; + } setCompletionSource(QmllsStatus::Source::EmbeddedCodeModel); setSemanticWarningSource(QmllsStatus::Source::EmbeddedCodeModel); setSemanticHighlightSource(QmllsStatus::Source::EmbeddedCodeModel); diff --git a/src/plugins/qmljseditor/qmllsclient.cpp b/src/plugins/qmljseditor/qmllsclient.cpp index 1fdc30a124a..3129fec7df5 100644 --- a/src/plugins/qmljseditor/qmllsclient.cpp +++ b/src/plugins/qmljseditor/qmllsclient.cpp @@ -45,6 +45,7 @@ static QHash &qmllsClients() QmllsClient *QmllsClient::clientForQmlls(const FilePath &qmlls) { + QTC_ASSERT(!qmlls.isEmpty(), return nullptr); if (auto client = qmllsClients()[qmlls]) { switch (client->state()) { case Client::State::Uninitialized: