From c3184ee79093098b7ac0193df46f41af7257306f Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 18 Feb 2015 17:31:43 +0100 Subject: [PATCH] Valgrind: Simplify callgrind context menu creation Change-Id: I5ea4bdf2dc6f4d3867e6abbc8d4cd6a1149a17b2 Reviewed-by: Christian Stenger --- src/plugins/valgrind/callgrindtool.cpp | 27 ++++---------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 2dc03c7785d..f8b9931eeba 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -150,7 +150,6 @@ public slots: void updateCostFormat(); void handleFilterProjectCosts(); - void handleShowCostsAction(); void handleShowCostsOfFunction(); void slotGoToOverview(); @@ -882,33 +881,15 @@ void CallgrindToolPrivate::editorOpened(IEditor *editor) void CallgrindToolPrivate::requestContextMenu(TextEditorWidget *widget, int line, QMenu *menu) { - // find callgrind text mark that corresponds to this editor's file and line number - const Function *func = 0; + // Find callgrind text mark that corresponds to this editor's file and line number foreach (CallgrindTextMark *textMark, m_textMarks) { if (textMark->fileName() == widget->textDocument()->filePath().toString() && textMark->lineNumber() == line) { - func = textMark->function(); + const Function *func = textMark->function(); + QAction *action = menu->addAction(tr("Select this Function in the Analyzer Output")); + connect(action, &QAction::triggered, this, [this, func] { selectFunction(func); }); break; } } - if (!func) - return; // no callgrind text mark under cursor, return - - // add our action to the context menu - QAction *action = new QAction(tr("Select this Function in the Analyzer Output"), menu); - connect(action, &QAction::triggered, this, &CallgrindToolPrivate::handleShowCostsAction); - action->setData(QVariant::fromValue(func)); - menu->addAction(action); -} - -void CallgrindToolPrivate::handleShowCostsAction() -{ - const QAction *action = qobject_cast(sender()); - QTC_ASSERT(action, return); - - const Function *func = action->data().value(); - QTC_ASSERT(func, return); - - selectFunction(func); } void CallgrindToolPrivate::handleShowCostsOfFunction()