mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-03 06:39:33 +00:00
Core: Only unlock CPU thread if CPUThreadGuard locked it
Before, I was getting an abort() call in debug builds when selecting Tools -> Load Wii System Menu (although I'm not sure if this will work on other machines consistently). It seems that CodeViewWidget::Update was constructing a CPUThreadGuard instance, and thus was calling Core::PauseAndLock(true, true), but the CPU thread hadn't started yet so Core::IsRunningAndStarted() returned false and thus Core::PauseAndLock() did nothing. However, after the code widget finished updating, CPUThreadGuard's destructor called PauseAndLock(false, true), and by this time the CPU thread *had* started so Core::PauseAndLock eventually called CPU::PauseAndLock(false, true, true). This resulted in s_stepping_lock.unlock() being called without a corresponding s_stepping_lock.lock() call, which calls abort() in debug builds.
This commit is contained in:
parent
982af34da3
commit
522470274d
2 changed files with 4 additions and 3 deletions
|
@ -1050,15 +1050,15 @@ void UpdateInputGate(bool require_focus, bool require_full_focus)
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUThreadGuard::CPUThreadGuard(Core::System& system)
|
CPUThreadGuard::CPUThreadGuard(Core::System& system)
|
||||||
: m_system(system), m_was_cpu_thread(IsCPUThread())
|
: m_system(system), m_was_cpu_thread(IsCPUThread()), m_has_cpu_thread(IsRunningAndStarted())
|
||||||
{
|
{
|
||||||
if (!m_was_cpu_thread)
|
if (m_has_cpu_thread && !m_was_cpu_thread)
|
||||||
m_was_unpaused = PauseAndLock(system, true, true);
|
m_was_unpaused = PauseAndLock(system, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUThreadGuard::~CPUThreadGuard()
|
CPUThreadGuard::~CPUThreadGuard()
|
||||||
{
|
{
|
||||||
if (!m_was_cpu_thread)
|
if (m_has_cpu_thread && !m_was_cpu_thread)
|
||||||
PauseAndLock(m_system, false, m_was_unpaused);
|
PauseAndLock(m_system, false, m_was_unpaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,7 @@ public:
|
||||||
private:
|
private:
|
||||||
Core::System& m_system;
|
Core::System& m_system;
|
||||||
const bool m_was_cpu_thread;
|
const bool m_was_cpu_thread;
|
||||||
|
const bool m_has_cpu_thread;
|
||||||
bool m_was_unpaused = false;
|
bool m_was_unpaused = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue