aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2022-11-07 13:34:45 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2022-11-08 08:14:37 +0000
commitc4ee485bdf98621fe0605b4ebf91008bfaa48c48 (patch)
treef3b6b77c4cd5125b48b4f799ed806ab8bf53b424
parenta1851c7cf1576a2656c251b193eb692b6caf480d (diff)
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 <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/plugins/clangcodemodel/clangdswitchdecldef.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/plugins/clangcodemodel/clangdswitchdecldef.cpp b/src/plugins/clangcodemodel/clangdswitchdecldef.cpp
index 7733516655..a60395292c 100644
--- a/src/plugins/clangcodemodel/clangdswitchdecldef.cpp
+++ b/src/plugins/clangcodemodel/clangdswitchdecldef.cpp
@@ -13,6 +13,7 @@
#include <utils/qtcassert.h>
#include <QApplication>
+#include <QMetaObject>
#include <QTextCursor>
#include <optional>
@@ -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<ClangdAstNode> ClangdSwitchDeclDef::Private::getFunctionNode() const