From a5a0a80464e948ab363e33b672489eda5a8692f4 Mon Sep 17 00:00:00 2001 From: BearOso Date: Wed, 17 Apr 2024 15:51:38 -0500 Subject: [PATCH] Qt: Fix cheats dialog. --- cheats2.cpp | 3 +++ qt/src/EmuApplication.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cheats2.cpp b/cheats2.cpp index bd491d29..8f8ac473 100644 --- a/cheats2.cpp +++ b/cheats2.cpp @@ -8,6 +8,7 @@ #include "cheats.h" #include "snes9x.h" #include "memmap.h" +#include static inline uint8 S9xGetByteFree(uint32 Address) { @@ -322,6 +323,8 @@ void S9xEnableCheat(SCheat &c) void S9xEnableCheatGroup(uint32 num) { + assert(num < Cheat.group.size()); + for (auto &c : Cheat.group[num].cheat) S9xEnableCheat(c); diff --git a/qt/src/EmuApplication.cpp b/qt/src/EmuApplication.cpp index cacb1d3b..d7c45762 100644 --- a/qt/src/EmuApplication.cpp +++ b/qt/src/EmuApplication.cpp @@ -543,14 +543,14 @@ void EmuApplication::disableAllCheats() void EmuApplication::enableCheat(int index) { - emu_thread->runOnThread([&] { + emu_thread->runOnThread([&, index] { core->enableCheat(index); }); } void EmuApplication::disableCheat(int index) { - emu_thread->runOnThread([&] { + emu_thread->runOnThread([&, index] { core->disableCheat(index); }); } @@ -565,7 +565,7 @@ bool EmuApplication::addCheat(std::string description, std::string code) void EmuApplication::deleteCheat(int index) { - emu_thread->runOnThread([&] { + emu_thread->runOnThread([&, index] { core->deleteCheat(index); }); }