From d8343b4b465b48cfaa0ea52dccc01b93415f004d Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 7 Dec 2022 09:32:03 +0100 Subject: [PATCH] Fix crash after closing preferences opened from indexing progress The preferences dialog is modal and creates an event loop that would be running within the mouse event handler of the widget. When the dialog is closed after the widget is destroyed (i.e. after indexing finished), control would be passed back to the destroyed widget, and crash. Fixes: QTCREATORBUG-28566 Change-Id: I71efa683822b5682ad1b38c39ce8f73c89bdd610 Reviewed-by: Christian Kandeler --- src/plugins/clangcodemodel/clangdclient.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index 329b91b6318..eec93aa46c9 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -394,7 +394,12 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir) project ? tr("Indexing %1 with clangd").arg(project->displayName()) : tr("Indexing session with clangd")); setClickHandlerForToken(indexingToken(), [] { - ICore::showOptionsDialog(CppEditor::Constants::CPP_CLANGD_SETTINGS_ID); + // don't directly open modal dialog from click handler, because that would mess + // up the stack + QMetaObject::invokeMethod( + ICore::instance(), + [] { ICore::showOptionsDialog(CppEditor::Constants::CPP_CLANGD_SETTINGS_ID); }, + Qt::QueuedConnection); }); setCurrentProject(project); setDocumentChangeUpdateThreshold(d->settings.documentUpdateThreshold);