From c4ee485bdf98621fe0605b4ebf91008bfaa48c48 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 7 Nov 2022 13:34:45 +0100 Subject: [PATCH] ClangCodeModel: Fix persistent SwitchDeclDef object If both AST and document symbols are available right away, the ClangdSwitchDeclDef object emits its done() signal before it is connected and stays around, potentially firing off new "follow symbol" requests to the bewilderment of innocent users. Fixes: QTCREATORBUG-28183 Change-Id: I972c8d4d9d7b7435e293d76fe710b19c9c4fb287 Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clangdswitchdecldef.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clangdswitchdecldef.cpp b/src/plugins/clangcodemodel/clangdswitchdecldef.cpp index 7733516655f..a60395292c1 100644 --- a/src/plugins/clangcodemodel/clangdswitchdecldef.cpp +++ b/src/plugins/clangcodemodel/clangdswitchdecldef.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -68,6 +69,7 @@ ClangdSwitchDeclDef::ClangdSwitchDeclDef(ClangdClient *client, TextDocument *doc [this](const DocumentUri &uri, const DocumentSymbolsResult &symbols) { if (uri != d->uri) return; + d->client->documentSymbolCache()->disconnect(this); d->docSymbols = symbols; if (d->ast) d->handleDeclDefSwitchReplies(); @@ -108,7 +110,7 @@ void ClangdSwitchDeclDef::emitDone() return; d->done = true; - emit done(); + QMetaObject::invokeMethod(this, &ClangdSwitchDeclDef::done, Qt::QueuedConnection); } std::optional ClangdSwitchDeclDef::Private::getFunctionNode() const