aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2022-12-07 09:32:03 +0100
committerEike Ziller <eike.ziller@qt.io>2022-12-07 09:26:10 +0000
commitd8343b4b465b48cfaa0ea52dccc01b93415f004d (patch)
treeb9793c58987ebb6a22c3b5df498cfcc560627818
parentf93404d405ed86a1e9b9825bc61e6b36c97783fa (diff)
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 <christian.kandeler@qt.io>
-rw-r--r--src/plugins/clangcodemodel/clangdclient.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp
index 329b91b631..eec93aa46c 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);