From ea6514b235bb6173ef346cdb6c42f9bc8d430aef Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Thu, 18 Sep 2014 15:40:43 +0200 Subject: [PATCH] C++: Show virtual functions menu only if resolving was requested That is, if the user does Ctrl+LeftClick or (Ctrl+E,) F2, but not on hover. The described bug in the report occurred because we immediately jump to an item if there is only one, e.g. in case of no overrides. That could also happen on hover, which lead to the undesired effect. Change-Id: I79f6fa1f90d37ea209da022d55d48aab2c13c21a Task-number: QTCREATORBUG-12986 Reviewed-by: David Schulz --- .../cppeditor/cppfollowsymbolundercursor.cpp | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp index 70ca15b5594..e5edad749c5 100644 --- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp +++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp @@ -669,33 +669,33 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor & if (Symbol *symbol = result.declaration()) { Symbol *def = 0; - // Consider to show a pop-up displaying overrides for the function - Function *function = symbol->type()->asFunctionType(); - VirtualFunctionHelper helper(*typeOfExpression, scope, doc, snapshot, symbolFinder); + if (resolveTarget) { + // Consider to show a pop-up displaying overrides for the function + Function *function = symbol->type()->asFunctionType(); + VirtualFunctionHelper helper(*typeOfExpression, scope, doc, snapshot, symbolFinder); - if (helper.canLookupVirtualFunctionOverrides(function)) { - VirtualFunctionAssistProvider::Parameters params; - params.function = function; - params.staticClass = helper.staticClassOfFunctionCallExpression(); - params.typeOfExpression = typeOfExpression; - params.snapshot = snapshot; - params.cursorPosition = cursor.position(); - params.openInNextSplit = inNextSplit; + if (helper.canLookupVirtualFunctionOverrides(function)) { + VirtualFunctionAssistProvider::Parameters params; + params.function = function; + params.staticClass = helper.staticClassOfFunctionCallExpression(); + params.typeOfExpression = typeOfExpression; + params.snapshot = snapshot; + params.cursorPosition = cursor.position(); + params.openInNextSplit = inNextSplit; - if (m_virtualFunctionAssistProvider->configure(params)) { - m_widget->invokeAssist(TextEditor::FollowSymbol, - m_virtualFunctionAssistProvider); - m_virtualFunctionAssistProvider->clearParams(); + if (m_virtualFunctionAssistProvider->configure(params)) { + m_widget->invokeAssist(TextEditor::FollowSymbol, + m_virtualFunctionAssistProvider); + m_virtualFunctionAssistProvider->clearParams(); + } + + // Ensure a valid link text, so the symbol name will be underlined on Ctrl+Hover. + Link link; + link.linkTextStart = beginOfToken; + link.linkTextEnd = endOfToken; + return link; } - // Ensure a valid link text, so the symbol name will be underlined on Ctrl+Hover. - Link link; - link.linkTextStart = beginOfToken; - link.linkTextEnd = endOfToken; - return link; - } - - if (resolveTarget) { Symbol *lastVisibleSymbol = doc->lastVisibleSymbolAt(line, column); def = findDefinition(symbol, snapshot, symbolFinder);