From 1a3f9155864ef8dc1731e0fc9c151a1889860f6e Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 21 Jun 2022 11:02:54 +0200 Subject: [PATCH] ClangCodeModel: Fix following virtual functions Amends 79b8e5397d340d70ad755c7bd8301846d89cafab. Change-Id: I8c4e3c7cb8cb26d51cdf77c15891110c6b213d46 Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clangdfollowsymbol.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/clangcodemodel/clangdfollowsymbol.cpp b/src/plugins/clangcodemodel/clangdfollowsymbol.cpp index 64993a03ba0..4c7400914ab 100644 --- a/src/plugins/clangcodemodel/clangdfollowsymbol.cpp +++ b/src/plugins/clangcodemodel/clangdfollowsymbol.cpp @@ -134,6 +134,7 @@ public: SymbolDataList symbolsToDisplay; std::set openedFiles; VirtualFunctionAssistProcessor *virtualFuncAssistProcessor = nullptr; + QMetaObject::Connection focusChangedConnection; bool finished = false; }; @@ -151,8 +152,8 @@ ClangdFollowSymbol::ClangdFollowSymbol(ClangdClient *client, const QTextCursor & connect(editorWidget, &CppEditorWidget::cursorPositionChanged, this, &ClangdFollowSymbol::done, Qt::QueuedConnection); } - connect(qApp, &QApplication::focusChanged, - this, &ClangdFollowSymbol::done, Qt::QueuedConnection); + d->focusChangedConnection = connect(qApp, &QApplication::focusChanged, + this, &ClangdFollowSymbol::done, Qt::QueuedConnection); // Step 1: Follow the symbol via "Go to Definition". At the same time, request the // AST node corresponding to the cursor position, so we can find out whether @@ -413,8 +414,10 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult( // As soon as we know that there is more than one candidate, we start the code assist // procedure, to let the user know that things are happening. - if (allLinks.size() > 1 && !virtualFuncAssistProcessor && editorWidget) + if (allLinks.size() > 1 && !virtualFuncAssistProcessor && editorWidget) { + QObject::disconnect(focusChangedConnection); editorWidget->invokeTextEditorWidgetAssist(FollowSymbol, &virtualFuncAssistProvider); + } if (!pendingGotoImplRequests.isEmpty()) return;