Allow seeking in unsynchronized widgets using 'g'. (#1731)

This commit is contained in:
karliss 2019-09-02 10:34:41 +03:00 committed by Itay Cohen
parent 567f852c3a
commit a4ba6f8b2b
3 changed files with 24 additions and 6 deletions

View File

@ -844,8 +844,8 @@ void MainWindow::updateDockActionsChecked()
MemoryWidgetType MainWindow::getMemoryWidgetTypeToRestore() MemoryWidgetType MainWindow::getMemoryWidgetTypeToRestore()
{ {
if (lastMemoryWidget) { if (lastSyncMemoryWidget) {
return lastMemoryWidget->getType(); return lastSyncMemoryWidget->getType();
} }
return MemoryWidgetType::Disassembly; return MemoryWidgetType::Disassembly;
} }
@ -876,8 +876,8 @@ QString MainWindow::getUniqueObjectName(const QString &widgetType) const
void MainWindow::showMemoryWidget() void MainWindow::showMemoryWidget()
{ {
if (lastMemoryWidget) { if (lastSyncMemoryWidget) {
if (lastMemoryWidget->tryRaiseMemoryWidget()) { if (lastSyncMemoryWidget->tryRaiseMemoryWidget()) {
return; return;
} }
} }
@ -929,8 +929,14 @@ QMenu *MainWindow::createShowInMenu(QWidget *parent, RVA address)
void MainWindow::setCurrentMemoryWidget(MemoryDockWidget *memoryWidget) void MainWindow::setCurrentMemoryWidget(MemoryDockWidget *memoryWidget)
{ {
if (memoryWidget->getSeekable()->isSynchronized()) { if (memoryWidget->getSeekable()->isSynchronized()) {
lastMemoryWidget = memoryWidget; lastSyncMemoryWidget = memoryWidget;
} }
lastMemoryWidget = memoryWidget;
}
MemoryDockWidget *MainWindow::getLastMemoryWidget()
{
return lastMemoryWidget;
} }
MemoryDockWidget *MainWindow::addNewMemoryWidget(MemoryWidgetType type, RVA address, MemoryDockWidget *MainWindow::addNewMemoryWidget(MemoryWidgetType type, RVA address,
@ -999,6 +1005,9 @@ void MainWindow::addMemoryDockWidget(MemoryDockWidget *widget)
void MainWindow::removeWidget(QDockWidget *widget) void MainWindow::removeWidget(QDockWidget *widget)
{ {
dockWidgets.removeAll(widget); dockWidgets.removeAll(widget);
if (lastSyncMemoryWidget == widget) {
lastSyncMemoryWidget = nullptr;
}
if (lastMemoryWidget == widget) { if (lastMemoryWidget == widget) {
lastMemoryWidget = nullptr; lastMemoryWidget = nullptr;
} }

View File

@ -120,6 +120,7 @@ public:
QMenu *createShowInMenu(QWidget *parent, RVA address); QMenu *createShowInMenu(QWidget *parent, RVA address);
void setCurrentMemoryWidget(MemoryDockWidget* memoryWidget); void setCurrentMemoryWidget(MemoryDockWidget* memoryWidget);
MemoryDockWidget* getLastMemoryWidget();
public slots: public slots:
void finalizeOpen(); void finalizeOpen();
@ -286,6 +287,7 @@ private:
*/ */
QMap<QString, std::function<CutterDockWidget*(MainWindow*, QAction*)>> widgetTypeToConstructorMap; QMap<QString, std::function<CutterDockWidget*(MainWindow*, QAction*)>> widgetTypeToConstructorMap;
MemoryDockWidget* lastSyncMemoryWidget = nullptr;
MemoryDockWidget* lastMemoryWidget = nullptr; MemoryDockWidget* lastMemoryWidget = nullptr;
}; };

View File

@ -1,5 +1,6 @@
#include "Omnibar.h" #include "Omnibar.h"
#include "core/MainWindow.h" #include "core/MainWindow.h"
#include "CutterSeekable.h"
#include <QStringListModel> #include <QStringListModel>
#include <QCompleter> #include <QCompleter>
@ -69,7 +70,13 @@ void Omnibar::on_gotoEntry_returnPressed()
{ {
QString str = this->text(); QString str = this->text();
if (!str.isEmpty()) { 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(""); this->setText("");