mirror of https://github.com/mgba-emu/mgba.git
Qt: Reset memory view region if jumped address is OOB (fixes #1043)
This commit is contained in:
parent
7d79db7d7d
commit
7020e45841
|
@ -149,12 +149,6 @@ void MemoryModel::jumpToAddress(const QString& hex) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -42,7 +42,7 @@ MemoryView::MemoryView(std::shared_ptr<CoreController> controller, QWidget* pare
|
|||
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 @@ void MemoryView::setIndex(int index) {
|
|||
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);
|
||||
|
@ -86,6 +87,17 @@ void MemoryView::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_selection.first = start;
|
||||
m_selection.second = end;
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue