From 289e660fb7bc1ac1e2ce7cd776aa65e2b069f7c6 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 18 Feb 2015 17:07:40 +0100 Subject: [PATCH] Debugger: Simplify code to open disassembler view from context menu Also, correct an off-by-one in column "computation" that always resulted in "no function" here from the C++ model which assumes column count starting at 1. Change-Id: I9a34d4ffaaa25131d5a130c57ec10f1ce8e8a184 Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggerplugin.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 581a27626d3..b0a4a3d35ae 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -903,15 +903,6 @@ public slots: } } - void slotDisassembleFunction() - { - const QAction *action = qobject_cast(sender()); - QTC_ASSERT(action, return); - const StackFrame frame = action->data().value(); - QTC_ASSERT(!frame.function.isEmpty(), return); - currentEngine()->openDisassemblerView(Location(frame)); - } - void handleAddToWatchWindow() { // Requires a selection, but that's the only case we want anyway. @@ -1738,18 +1729,18 @@ void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget, }); } // Disassemble current function in stopped state. - if (currentEngine()->state() == InferiorStopOk - && currentEngine()->hasCapability(DisassemblerCapability)) { + if (currentEngine()->hasCapability(DisassemblerCapability)) { StackFrame frame; - frame.function = cppFunctionAt(args.fileName, lineNumber); + frame.function = cppFunctionAt(args.fileName, lineNumber, 1); frame.line = 42; // trick gdb into mixed mode. if (!frame.function.isEmpty()) { const QString text = tr("Disassemble Function \"%1\"") .arg(frame.function); - QAction *disassembleAction = new QAction(text, menu); - disassembleAction->setData(QVariant::fromValue(frame)); - connect(disassembleAction, &QAction::triggered, this, &DebuggerPluginPrivate::slotDisassembleFunction); - menu->addAction(disassembleAction ); + auto act = new QAction(text, menu); + connect(act, &QAction::triggered, [this, frame] { + currentEngine()->openDisassemblerView(Location(frame)); + }); + menu->addAction(act); } } }