forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user