Skip to content

Commit

Permalink
Cheats: Serialize access to zips
Browse files Browse the repository at this point in the history
Prevents the UI thread from trashing the zip struct while the
emulation thread is also reading.
  • Loading branch information
stenzek committed Oct 20, 2024
1 parent 5c4a9f9 commit 6cc350a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ const char* PATCHES_CONFIG_SECTION = "Patches";
const char* CHEATS_CONFIG_SECTION = "Cheats";
const char* PATCH_ENABLE_CONFIG_KEY = "Enable";

static std::mutex s_zip_mutex;
static CheatArchive s_patches_zip;
static CheatArchive s_cheats_zip;
static CheatCodeList s_patch_codes;
Expand Down Expand Up @@ -365,6 +366,7 @@ void Cheats::EnumerateChtFiles(const std::string_view serial, std::optional<Game
// Prefer files on disk over the zip, so we have to load the zip first.
if (load_from_database)
{
const std::unique_lock lock(s_zip_mutex);
CheatArchive& archive = cheats ? s_cheats_zip : s_patches_zip;
if (!archive.IsOpen())
{
Expand Down

0 comments on commit 6cc350a

Please sign in to comment.