diff --git a/Core/Debugger/Breakpoints.cpp b/Core/Debugger/Breakpoints.cpp index 5e6849ced9..eea01ba1fa 100644 --- a/Core/Debugger/Breakpoints.cpp +++ b/Core/Debugger/Breakpoints.cpp @@ -216,15 +216,30 @@ void BreakpointManager::ClearTemporaryBreakPoints() { if (!anyBreakPoints_) return; + std::unique_lock guard(breakPointsMutex_); - for (int i = (int)breakPoints_.size()-1; i >= 0; --i) - { - if (breakPoints_[i].temporary) - { - breakPoints_.erase(breakPoints_.begin() + i); - Update(); + + std::vector addrsToUpdate; + + for (auto it = breakPoints_.begin(); it != breakPoints_.end(); ) { + if (it->temporary) { + addrsToUpdate.push_back(it->addr); + it = breakPoints_.erase(it); + } else { + ++it; } } + + if (addrsToUpdate.size() == 1) { + // We can use the proper mechanism to update just one address. + // If there are any temp breakpoints, there's normally just one, so this is better + // than Update(). + Update(addrsToUpdate[0]); + } else if (!addrsToUpdate.empty()) { + Update(); + } + + anyBreakPoints_ = !breakPoints_.empty(); } void BreakpointManager::ChangeBreakPointAddCond(u32 addr, const BreakPointCond &cond)