forked from qt-creator/qt-creator
LanguageClient: prevent accessing freed data on shutdown
Change-Id: I0d6e7abd653acb2ab7409a9cd5e58a2df3b1f259 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -190,19 +190,23 @@ public:
|
||||
// temporary container needed since m_resetAssistProvider is changed in resetAssistProviders
|
||||
for (TextDocument *document : m_resetAssistProvider.keys())
|
||||
resetAssistProviders(document);
|
||||
if (!LanguageClientManager::isShuttingDown()) {
|
||||
// prevent accessing deleted editors on Creator shutdown
|
||||
const QList<Core::IEditor *> &editors = Core::DocumentModel::editorsForOpenedDocuments();
|
||||
for (Core::IEditor *editor : editors) {
|
||||
if (auto textEditor = qobject_cast<BaseTextEditor *>(editor)) {
|
||||
TextEditorWidget *widget = textEditor->editorWidget();
|
||||
widget->setRefactorMarkers(RefactorMarker::filterOutType(widget->refactorMarkers(), m_id));
|
||||
widget->setRefactorMarkers(
|
||||
RefactorMarker::filterOutType(widget->refactorMarkers(), m_id));
|
||||
widget->removeHoverHandler(&m_hoverHandler);
|
||||
}
|
||||
}
|
||||
updateEditorToolBar(m_openedDocument.keys());
|
||||
}
|
||||
for (IAssistProcessor *processor : qAsConst(m_runningAssistProcessors))
|
||||
processor->setAsyncProposalAvailable(nullptr);
|
||||
qDeleteAll(m_documentHighlightsTimer);
|
||||
m_documentHighlightsTimer.clear();
|
||||
updateEditorToolBar(m_openedDocument.keys());
|
||||
// do not handle messages while shutting down
|
||||
disconnect(m_clientInterface, &InterfaceController::messageReceived,
|
||||
q, &Client::handleMessage);
|
||||
|
||||
@@ -232,6 +232,11 @@ void LanguageClientManager::shutdown()
|
||||
});
|
||||
}
|
||||
|
||||
bool LanguageClientManager::isShuttingDown()
|
||||
{
|
||||
return managerInstance->m_shuttingDown;
|
||||
}
|
||||
|
||||
LanguageClientManager *LanguageClientManager::instance()
|
||||
{
|
||||
return managerInstance;
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
static void deleteClient(Client *client);
|
||||
|
||||
static void shutdown();
|
||||
static bool isShuttingDown();
|
||||
|
||||
static LanguageClientManager *instance();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user