diff --git a/src/core/MainWindow.cpp b/src/core/MainWindow.cpp index 9cb81988..e812e43d 100644 --- a/src/core/MainWindow.cpp +++ b/src/core/MainWindow.cpp @@ -844,8 +844,8 @@ void MainWindow::updateDockActionsChecked() MemoryWidgetType MainWindow::getMemoryWidgetTypeToRestore() { - if (lastMemoryWidget) { - return lastMemoryWidget->getType(); + if (lastSyncMemoryWidget) { + return lastSyncMemoryWidget->getType(); } return MemoryWidgetType::Disassembly; } @@ -876,8 +876,8 @@ QString MainWindow::getUniqueObjectName(const QString &widgetType) const void MainWindow::showMemoryWidget() { - if (lastMemoryWidget) { - if (lastMemoryWidget->tryRaiseMemoryWidget()) { + if (lastSyncMemoryWidget) { + if (lastSyncMemoryWidget->tryRaiseMemoryWidget()) { return; } } @@ -929,8 +929,14 @@ QMenu *MainWindow::createShowInMenu(QWidget *parent, RVA address) void MainWindow::setCurrentMemoryWidget(MemoryDockWidget *memoryWidget) { if (memoryWidget->getSeekable()->isSynchronized()) { - lastMemoryWidget = memoryWidget; + lastSyncMemoryWidget = memoryWidget; } + lastMemoryWidget = memoryWidget; +} + +MemoryDockWidget *MainWindow::getLastMemoryWidget() +{ + return lastMemoryWidget; } MemoryDockWidget *MainWindow::addNewMemoryWidget(MemoryWidgetType type, RVA address, @@ -999,6 +1005,9 @@ void MainWindow::addMemoryDockWidget(MemoryDockWidget *widget) void MainWindow::removeWidget(QDockWidget *widget) { dockWidgets.removeAll(widget); + if (lastSyncMemoryWidget == widget) { + lastSyncMemoryWidget = nullptr; + } if (lastMemoryWidget == widget) { lastMemoryWidget = nullptr; } diff --git a/src/core/MainWindow.h b/src/core/MainWindow.h index 2f784c8f..6756c0a2 100644 --- a/src/core/MainWindow.h +++ b/src/core/MainWindow.h @@ -120,6 +120,7 @@ public: QMenu *createShowInMenu(QWidget *parent, RVA address); void setCurrentMemoryWidget(MemoryDockWidget* memoryWidget); + MemoryDockWidget* getLastMemoryWidget(); public slots: void finalizeOpen(); @@ -286,6 +287,7 @@ private: */ QMap> widgetTypeToConstructorMap; + MemoryDockWidget* lastSyncMemoryWidget = nullptr; MemoryDockWidget* lastMemoryWidget = nullptr; }; diff --git a/src/widgets/Omnibar.cpp b/src/widgets/Omnibar.cpp index 3959afa9..bbb42982 100644 --- a/src/widgets/Omnibar.cpp +++ b/src/widgets/Omnibar.cpp @@ -1,5 +1,6 @@ #include "Omnibar.h" #include "core/MainWindow.h" +#include "CutterSeekable.h" #include #include @@ -69,7 +70,13 @@ void Omnibar::on_gotoEntry_returnPressed() { QString str = this->text(); if (!str.isEmpty()) { - Core()->seekAndShow(str); + if (auto memoryWidget = main->getLastMemoryWidget()) { + RVA offset = Core()->math(str); + memoryWidget->getSeekable()->seek(offset); + memoryWidget->raiseMemoryWidget(); + } else { + Core()->seekAndShow(str); + } } this->setText("");