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 <sami.shalayel@qt.io>
This commit is contained in:
David Schulz
2024-12-11 15:44:51 +01:00
parent 59174398c8
commit 04fc1fcbce
2 changed files with 3 additions and 4 deletions

View File

@@ -765,7 +765,7 @@ void QmlJSEditorDocumentPrivate::settingsChanged()
return; return;
FilePath newQmlls = qmllsForFile(q->filePath(), ModelManagerInterface::instance()); 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)) { if (QmllsClient *client = QmllsClient::clientForQmlls(newQmlls)) {
client->updateQmllsSemanticHighlightingCapability(); client->updateQmllsSemanticHighlightingCapability();
setSourcesWithCapabilities(client->capabilities()); setSourcesWithCapabilities(client->capabilities());
@@ -781,9 +781,7 @@ void QmlJSEditorDocumentPrivate::settingsChanged()
if (LanguageClientManager::clientForDocument(q) != nullptr) { if (LanguageClientManager::clientForDocument(q) != nullptr) {
qCDebug(qmllsLog) << "deactivating " << q->filePath() << "in qmlls" << newQmlls; qCDebug(qmllsLog) << "deactivating " << q->filePath() << "in qmlls" << newQmlls;
LanguageClientManager::openDocumentWithClient(q, nullptr); LanguageClientManager::openDocumentWithClient(q, nullptr);
} else }
qCWarning(qmllsLog) << "Could not find client to disable for document " << q->filePath()
<< " in LanguageClient::LanguageClientManager";
setCompletionSource(QmllsStatus::Source::EmbeddedCodeModel); setCompletionSource(QmllsStatus::Source::EmbeddedCodeModel);
setSemanticWarningSource(QmllsStatus::Source::EmbeddedCodeModel); setSemanticWarningSource(QmllsStatus::Source::EmbeddedCodeModel);
setSemanticHighlightSource(QmllsStatus::Source::EmbeddedCodeModel); setSemanticHighlightSource(QmllsStatus::Source::EmbeddedCodeModel);

View File

@@ -45,6 +45,7 @@ static QHash<FilePath, QmllsClient *> &qmllsClients()
QmllsClient *QmllsClient::clientForQmlls(const FilePath &qmlls) QmllsClient *QmllsClient::clientForQmlls(const FilePath &qmlls)
{ {
QTC_ASSERT(!qmlls.isEmpty(), return nullptr);
if (auto client = qmllsClients()[qmlls]) { if (auto client = qmllsClients()[qmlls]) {
switch (client->state()) { switch (client->state()) {
case Client::State::Uninitialized: case Client::State::Uninitialized: