Qt: Reset memory view region if jumped address is OOB (fixes #1043)
Vicki Pfau vi@endrift.com
Sun, 02 Sep 2018 15:43:59 -0700
3 files changed,
15 insertions(+),
8 deletions(-)
M
src/platform/qt/MemoryModel.cpp
→
src/platform/qt/MemoryModel.cpp
@@ -149,12 +149,6 @@ }
} void MemoryModel::jumpToAddress(uint32_t address) { - if (address >= 0x10000000) { - return; - } - if (address < m_base || address >= m_base + m_size) { - setRegion(0, 0x10000000, tr("All")); - } m_top = (address - m_base) / 16; boundsCheck(); verticalScrollBar()->setValue(m_top);
M
src/platform/qt/MemoryView.cpp
→
src/platform/qt/MemoryView.cpp
@@ -42,7 +42,7 @@ connect(m_ui.width8, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(1); });
connect(m_ui.width16, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(2); }); connect(m_ui.width32, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(4); }); connect(m_ui.setAddress, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), - m_ui.hexfield, static_cast<void (MemoryModel::*)(uint32_t)>(&MemoryModel::jumpToAddress)); + this, static_cast<void (MemoryView::*)(uint32_t)>(&MemoryView::jumpToAddress)); connect(m_ui.hexfield, &MemoryModel::selectionChanged, this, &MemoryView::updateSelection); connect(controller.get(), &CoreController::stopping, this, &QWidget::close);@@ -66,6 +66,7 @@ const mCoreMemoryBlock* blocks;
size_t nBlocks = core->listMemoryBlocks(core, &blocks); const mCoreMemoryBlock& info = blocks[index]; + m_region = qMakePair(info.start, info.end); m_ui.segments->setValue(-1); m_ui.segments->setVisible(info.maxSegment > 0); m_ui.segments->setMaximum(info.maxSegment);@@ -84,6 +85,17 @@
void MemoryView::update() { m_ui.hexfield->viewport()->update(); updateStatus(); +} + +void MemoryView::jumpToAddress(uint32_t address) { + if (address < m_region.first || address >= m_region.second) { + m_ui.regions->setCurrentIndex(0); + setIndex(0); + } + if (address < m_region.first || address >= m_region.second) { + return; + } + m_ui.hexfield->jumpToAddress(address); } void MemoryView::updateSelection(uint32_t start, uint32_t end) {
M
src/platform/qt/MemoryView.h
→
src/platform/qt/MemoryView.h
@@ -21,7 +21,7 @@ MemoryView(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
public slots: void update(); - void jumpToAddress(uint32_t address) { m_ui.hexfield->jumpToAddress(address); } + void jumpToAddress(uint32_t address); private slots: void setIndex(int);@@ -33,6 +33,7 @@ private:
Ui::MemoryView m_ui; std::shared_ptr<CoreController> m_controller; + QPair<uint32_t, uint32_t> m_region; QPair<uint32_t, uint32_t> m_selection; };