LanguageClient: fix multiple crashes in languageClient

The temporary containers are needed in some places because the content of the containers change
while iterating over them.
partially reverts: cf010911f7

Change-Id: I4d6df987b9e5382b6b18fa659b1174ca6919a02e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2021-01-22 14:26:11 +01:00
parent fecb0a4c83
commit 4f1c5bacb9
3 changed files with 9 additions and 8 deletions

View File

@@ -387,13 +387,13 @@ void LanguageClientManager::clientFinished(Client *client)
client->disconnect(this);
client->log(tr("Unexpectedly finished. Restarting in %1 seconds.").arg(restartTimeoutS));
QTimer::singleShot(restartTimeoutS * 1000, client, [client]() { startClient(client); });
for (auto it = m_clientForDocument.cbegin(); it != m_clientForDocument.cend(); ++it)
client->deactivateDocument(it.key());
for (TextEditor::TextDocument *document : m_clientForDocument.keys(client))
client->deactivateDocument(document);
} else {
if (unexpectedFinish && !m_shuttingDown)
client->log(tr("Unexpectedly finished."));
for (auto it = m_clientForDocument.cbegin(); it != m_clientForDocument.cend(); ++it)
m_clientForDocument.remove(it.key());
for (TextEditor::TextDocument *document : m_clientForDocument.keys(client))
m_clientForDocument.remove(document);
deleteClient(client);
if (m_shuttingDown && m_clients.isEmpty())
emit shutdownFinished();