forked from qt-creator/qt-creator
LanguageClient: fix race condition on client shutdown
If a document is closed between removing a closing client from the tracked clients in the LanguageClientManager and the actual destruction of that client we might derefernce an already desctructed document in resetAssistProvider. Connect the document closed signal in the client instead of the manager so Client::closeDocument gets called even if it is not tracked in the manager anymore. Fixes: QTCREATORBUG-26534 Change-Id: I7187730600eeb1df54355065eb9cb703a605139e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -542,11 +542,8 @@ void LanguageClientManager::documentOpened(Core::IDocument *document)
|
||||
|
||||
void LanguageClientManager::documentClosed(Core::IDocument *document)
|
||||
{
|
||||
if (auto textDocument = qobject_cast<TextEditor::TextDocument *>(document)) {
|
||||
for (Client *client : qAsConst(m_clients))
|
||||
client->closeDocument(textDocument);
|
||||
if (auto textDocument = qobject_cast<TextEditor::TextDocument *>(document))
|
||||
m_clientForDocument.remove(textDocument);
|
||||
}
|
||||
}
|
||||
|
||||
void LanguageClientManager::documentContentsSaved(Core::IDocument *document)
|
||||
|
||||
Reference in New Issue
Block a user