mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
DolphinQt: Properly lock CPU before accessing emulated memory
This fixes a problem I was having where using frame advance with the debugger open would frequently cause panic alerts about invalid addresses due to the CPU thread changing MSR.DR while the host thread was trying to access memory. To aid in tracking down all the places where we weren't properly locking the CPU, I've created a new type (in Core.h) that you have to pass as a reference or pointer to functions that require running as the CPU thread.
This commit is contained in:
@ -36,6 +36,7 @@
|
||||
#include "Core/CheatGeneration.h"
|
||||
#include "Core/CheatSearch.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
#include "DolphinQt/Config/CheatCodeEditor.h"
|
||||
@ -286,7 +287,11 @@ void CheatSearchWidget::OnNextScanClicked()
|
||||
return;
|
||||
}
|
||||
}
|
||||
Cheats::SearchErrorCode error_code = m_session->RunSearch();
|
||||
|
||||
const Cheats::SearchErrorCode error_code = [this] {
|
||||
Core::CPUThreadGuard guard;
|
||||
return m_session->RunSearch(guard);
|
||||
}();
|
||||
|
||||
if (error_code == Cheats::SearchErrorCode::Success)
|
||||
{
|
||||
@ -391,7 +396,13 @@ bool CheatSearchWidget::RefreshValues()
|
||||
}
|
||||
|
||||
tmp->SetFilterType(Cheats::FilterType::DoNotFilter);
|
||||
if (tmp->RunSearch() != Cheats::SearchErrorCode::Success)
|
||||
|
||||
const Cheats::SearchErrorCode error_code = [&tmp] {
|
||||
Core::CPUThreadGuard guard;
|
||||
return tmp->RunSearch(guard);
|
||||
}();
|
||||
|
||||
if (error_code != Cheats::SearchErrorCode::Success)
|
||||
{
|
||||
m_info_label_1->setText(tr("Refresh failed. Please run the game for a bit and try again."));
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user