forked from qt-creator/qt-creator
LanguageClient: properly deactivate documents for closing Clients
Deactivating the documents resets all client specific data and objects in the document like the formatter or highlighting information. Fixes an assert in the LanguageClientFormatter. Change-Id: I7069abb273749ae335fed11010a5055eacaf58b2 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -168,10 +168,10 @@ void LanguageClientManager::clientFinished(Client *client)
|
|||||||
const bool unexpectedFinish = client->state() != Client::Shutdown
|
const bool unexpectedFinish = client->state() != Client::Shutdown
|
||||||
&& client->state() != Client::ShutdownRequested;
|
&& client->state() != Client::ShutdownRequested;
|
||||||
|
|
||||||
if (unexpectedFinish) {
|
|
||||||
if (!PluginManager::isShuttingDown()) {
|
|
||||||
const QList<TextEditor::TextDocument *> &clientDocs
|
const QList<TextEditor::TextDocument *> &clientDocs
|
||||||
= managerInstance->m_clientForDocument.keys(client);
|
= managerInstance->m_clientForDocument.keys(client);
|
||||||
|
if (unexpectedFinish) {
|
||||||
|
if (!PluginManager::isShuttingDown()) {
|
||||||
if (client->state() == Client::Initialized && client->reset()) {
|
if (client->state() == Client::Initialized && client->reset()) {
|
||||||
qCDebug(Log) << "restart unexpectedly finished client: " << client->name() << client;
|
qCDebug(Log) << "restart unexpectedly finished client: " << client->name() << client;
|
||||||
client->log(
|
client->log(
|
||||||
@@ -186,10 +186,14 @@ void LanguageClientManager::clientFinished(Client *client)
|
|||||||
}
|
}
|
||||||
qCDebug(Log) << "client finished unexpectedly: " << client->name() << client;
|
qCDebug(Log) << "client finished unexpectedly: " << client->name() << client;
|
||||||
client->log(Tr::tr("Unexpectedly finished."));
|
client->log(Tr::tr("Unexpectedly finished."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unexpectedFinish || !QTC_GUARD(clientDocs.isEmpty())) {
|
||||||
for (TextEditor::TextDocument *document : clientDocs)
|
for (TextEditor::TextDocument *document : clientDocs)
|
||||||
managerInstance->m_clientForDocument.remove(document);
|
openDocumentWithClient(document, nullptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteClient(client);
|
deleteClient(client);
|
||||||
if (isShutdownFinished())
|
if (isShutdownFinished())
|
||||||
emit managerInstance->shutdownFinished();
|
emit managerInstance->shutdownFinished();
|
||||||
|
|||||||
Reference in New Issue
Block a user