LanguageClientManager: Don't delete the client directly

LanguageClientManager::deleteClient() may be called directly
from Client::finished() handler, from BaseClientInterface::finished()
handler, from StdIOClientInterface::onProcessFinished() handler
or from QtcProcess::finished() handler. Don't delete
directly any of this objects - delete later instead.

Since now we have delayed the deletion of clients, we can't
send directly the shutdownFinished() signal,
as we have not really finished the shutdown yet.
Since all the calls to clients' deleteLater() were
scheduled before emitting shutdownFinished(),
we send the signal using queued connection, which should
guarantee that all clients' destructor were already executed
before calling asynchronousShutdownFinished().

Task-number: QTCREATORBUG-27316
Change-Id: I4f2c8a756ca86c36cc6324af14b99a9fd4513cd3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Jarek Kobus
2022-04-04 17:27:49 +02:00
parent 4093fbe826
commit c4e75b7e20
2 changed files with 3 additions and 6 deletions

View File

@@ -236,13 +236,10 @@ void LanguageClientManager::deleteClient(Client *client)
managerInstance->m_clients.removeAll(client);
for (QList<Client *> &clients : managerInstance->m_clientsForSetting)
clients.removeAll(client);
if (managerInstance->m_shuttingDown) {
delete client;
} else {
client->deleteLater();
if (!managerInstance->m_shuttingDown)
emit instance()->clientRemoved(client);
}
}
void LanguageClientManager::shutdown()
{

View File

@@ -87,7 +87,7 @@ ExtensionSystem::IPlugin::ShutdownFlag LanguageClientPlugin::aboutToShutdown()
QTC_ASSERT(LanguageClientManager::instance(),
return ExtensionSystem::IPlugin::SynchronousShutdown);
connect(LanguageClientManager::instance(), &LanguageClientManager::shutdownFinished,
this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished);
this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished, Qt::QueuedConnection);
return ExtensionSystem::IPlugin::AsynchronousShutdown;
}