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
|
// temporary container needed since m_resetAssistProvider is changed in resetAssistProviders
|
||||||
for (TextDocument *document : m_resetAssistProvider.keys())
|
for (TextDocument *document : m_resetAssistProvider.keys())
|
||||||
resetAssistProviders(document);
|
resetAssistProviders(document);
|
||||||
const QList<Core::IEditor *> &editors = Core::DocumentModel::editorsForOpenedDocuments();
|
if (!LanguageClientManager::isShuttingDown()) {
|
||||||
for (Core::IEditor *editor : editors) {
|
// prevent accessing deleted editors on Creator shutdown
|
||||||
if (auto textEditor = qobject_cast<BaseTextEditor *>(editor)) {
|
const QList<Core::IEditor *> &editors = Core::DocumentModel::editorsForOpenedDocuments();
|
||||||
TextEditorWidget *widget = textEditor->editorWidget();
|
for (Core::IEditor *editor : editors) {
|
||||||
widget->setRefactorMarkers(RefactorMarker::filterOutType(widget->refactorMarkers(), m_id));
|
if (auto textEditor = qobject_cast<BaseTextEditor *>(editor)) {
|
||||||
widget->removeHoverHandler(&m_hoverHandler);
|
TextEditorWidget *widget = textEditor->editorWidget();
|
||||||
|
widget->setRefactorMarkers(
|
||||||
|
RefactorMarker::filterOutType(widget->refactorMarkers(), m_id));
|
||||||
|
widget->removeHoverHandler(&m_hoverHandler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
updateEditorToolBar(m_openedDocument.keys());
|
||||||
}
|
}
|
||||||
for (IAssistProcessor *processor : qAsConst(m_runningAssistProcessors))
|
for (IAssistProcessor *processor : qAsConst(m_runningAssistProcessors))
|
||||||
processor->setAsyncProposalAvailable(nullptr);
|
processor->setAsyncProposalAvailable(nullptr);
|
||||||
qDeleteAll(m_documentHighlightsTimer);
|
qDeleteAll(m_documentHighlightsTimer);
|
||||||
m_documentHighlightsTimer.clear();
|
m_documentHighlightsTimer.clear();
|
||||||
updateEditorToolBar(m_openedDocument.keys());
|
|
||||||
// do not handle messages while shutting down
|
// do not handle messages while shutting down
|
||||||
disconnect(m_clientInterface, &InterfaceController::messageReceived,
|
disconnect(m_clientInterface, &InterfaceController::messageReceived,
|
||||||
q, &Client::handleMessage);
|
q, &Client::handleMessage);
|
||||||
|
|||||||
@@ -232,6 +232,11 @@ void LanguageClientManager::shutdown()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LanguageClientManager::isShuttingDown()
|
||||||
|
{
|
||||||
|
return managerInstance->m_shuttingDown;
|
||||||
|
}
|
||||||
|
|
||||||
LanguageClientManager *LanguageClientManager::instance()
|
LanguageClientManager *LanguageClientManager::instance()
|
||||||
{
|
{
|
||||||
return managerInstance;
|
return managerInstance;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public:
|
|||||||
static void deleteClient(Client *client);
|
static void deleteClient(Client *client);
|
||||||
|
|
||||||
static void shutdown();
|
static void shutdown();
|
||||||
|
static bool isShuttingDown();
|
||||||
|
|
||||||
static LanguageClientManager *instance();
|
static LanguageClientManager *instance();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user