PowerPC: Add RAII handling for breakpoint updates

bbf72e7 made a change where you can pass `false` to certain MemChecks
functions to get them to skip performing an "update" step. It was then
up to the caller to call the Update function later.

This commit changes the implementation so that, instead of the caller
passing in a boolean that controls whether a function calls Update, the
function now returns an object that on destruction will call Update.
Callers that are fine with Update being called right away can skip
storing the object in a variable and thereby call Update immediately,
and callers that want to call Update later can keep the object around.
This new design reduces the risk that someone will forget calling
Update.
This commit is contained in:
JosJuice
2025-03-22 12:13:48 +01:00
parent 049e52ce1c
commit 303366b1ce
4 changed files with 52 additions and 20 deletions

View File

@ -996,6 +996,7 @@ void MemoryViewWidget::ToggleBreakpoint(u32 addr, bool row)
{
const Core::CPUThreadGuard guard(m_system);
DelayedMemCheckUpdate delayed_update(&memchecks);
for (int i = 0; i < breaks; i++)
{
@ -1014,16 +1015,14 @@ void MemoryViewWidget::ToggleBreakpoint(u32 addr, bool row)
check.log_on_hit = m_do_log;
check.break_on_hit = true;
memchecks.Add(std::move(check), false);
delayed_update |= memchecks.Add(std::move(check));
}
else if (check_ptr != nullptr)
{
// Using the pointer fixes misaligned breakpoints (0x11 breakpoint in 0x10 aligned view).
memchecks.Remove(check_ptr->start_address, false);
delayed_update |= memchecks.Remove(check_ptr->start_address);
}
}
memchecks.Update();
}
emit Host::GetInstance()->PPCBreakpointsChanged();