From ae1e15b7a2ed74b474b1f0fb72acccb25cffdb3a Mon Sep 17 00:00:00 2001 From: Theofilos Pechlivanis Date: Sat, 29 Oct 2022 21:57:30 +0300 Subject: [PATCH] Keep CallGraph widget active when seeking to other functions --- src/core/MainWindow.cpp | 6 ++++++ src/widgets/CallGraph.cpp | 9 +++++++-- src/widgets/CallGraph.h | 6 ++++-- src/widgets/MemoryDockWidget.h | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/core/MainWindow.cpp b/src/core/MainWindow.cpp index 6a840fcc..46c6fac0 100644 --- a/src/core/MainWindow.cpp +++ b/src/core/MainWindow.cpp @@ -1086,6 +1086,12 @@ MemoryDockWidget *MainWindow::addNewMemoryWidget(MemoryWidgetType type, RVA addr case MemoryWidgetType::Decompiler: memoryWidget = new DecompilerWidget(this); break; + case MemoryWidgetType::CallGraph: + memoryWidget = new CallGraphWidget(this, false); + break; + case MemoryWidgetType::GlobalCallGraph: + memoryWidget = new CallGraphWidget(this, true); + break; } auto seekable = memoryWidget->getSeekable(); seekable->setSynchronization(synchronized); diff --git a/src/widgets/CallGraph.cpp b/src/widgets/CallGraph.cpp index 8c3d7e4a..64736573 100644 --- a/src/widgets/CallGraph.cpp +++ b/src/widgets/CallGraph.cpp @@ -7,9 +7,9 @@ #include CallGraphWidget::CallGraphWidget(MainWindow *main, bool global) - : AddressableDockWidget(main), graphView(new CallGraphView(this, main, global)), global(global) + : MemoryDockWidget(MemoryWidgetType::CallGraph, main), graphView(new CallGraphView(this, main, global)), global(global) { - setObjectName(main->getUniqueObjectName("CallGraphWidget")); + setObjectName(main ? main->getUniqueObjectName(getWidgetType()) : getWidgetType()); this->setWindowTitle(getWindowTitle()); connect(seekable, &CutterSeekable::seekableSeekChanged, this, &CallGraphWidget::onSeekChanged); @@ -23,6 +23,11 @@ QString CallGraphWidget::getWindowTitle() const return global ? tr("Global Callgraph") : tr("Callgraph"); } +QString CallGraphWidget::getWidgetType() const +{ + return global ? tr("GlobalCallgraph") : tr("Callgraph"); +} + void CallGraphWidget::onSeekChanged(RVA address) { if (auto function = Core()->functionIn(address)) { diff --git a/src/widgets/CallGraph.h b/src/widgets/CallGraph.h index 2d348266..2c6e0a96 100644 --- a/src/widgets/CallGraph.h +++ b/src/widgets/CallGraph.h @@ -2,7 +2,7 @@ #define CALL_GRAPH_WIDGET_H #include "core/Cutter.h" -#include "AddressableDockWidget.h" +#include "MemoryDockWidget.h" #include "widgets/SimpleTextGraphView.h" #include "common/RefreshDeferrer.h" @@ -30,7 +30,7 @@ private: RVA lastLoadedAddress = RVA_INVALID; }; -class CallGraphWidget : public AddressableDockWidget +class CallGraphWidget : public MemoryDockWidget { Q_OBJECT @@ -38,6 +38,8 @@ public: explicit CallGraphWidget(MainWindow *main, bool global); ~CallGraphWidget(); + QString getWidgetType() const; + protected: QString getWindowTitle() const override; diff --git a/src/widgets/MemoryDockWidget.h b/src/widgets/MemoryDockWidget.h index 51d0ca88..0b1a5952 100644 --- a/src/widgets/MemoryDockWidget.h +++ b/src/widgets/MemoryDockWidget.h @@ -7,7 +7,7 @@ #include /* Disassembly/Graph/Hexdump/Decompiler view priority */ -enum class MemoryWidgetType { Disassembly, Graph, Hexdump, Decompiler }; +enum class MemoryWidgetType { Disassembly, Graph, Hexdump, Decompiler, CallGraph, GlobalCallGraph }; class CUTTER_EXPORT MemoryDockWidget : public AddressableDockWidget {