cheats: don't update the cheat list when adding one fails
The operation should fail or succeed completely. Issue #871
This commit is contained in:
parent
13428ba696
commit
8aadf5b097
|
@ -623,6 +623,8 @@ void CheatManager::addGameSharkCheat(const std::string& name, const std::string&
|
|||
Cheat conditionCheat;
|
||||
unsigned conditionLimit = 0;
|
||||
|
||||
const size_t prevSize = cheats.size();
|
||||
try {
|
||||
for (unsigned i = 0; i < codes.size(); i++)
|
||||
{
|
||||
if (i < conditionLimit)
|
||||
|
@ -807,7 +809,6 @@ void CheatManager::addGameSharkCheat(const std::string& name, const std::string&
|
|||
throw FlycastException("Unsupported cheat type");
|
||||
}
|
||||
}
|
||||
setActive(!cheats.empty());
|
||||
#ifndef LIBRETRO
|
||||
std::string path = cfgLoadStr("cheats", gameId, "");
|
||||
if (path == "")
|
||||
|
@ -817,6 +818,11 @@ void CheatManager::addGameSharkCheat(const std::string& name, const std::string&
|
|||
}
|
||||
saveCheatFile(path);
|
||||
#endif
|
||||
setActive(!cheats.empty());
|
||||
} catch (...) {
|
||||
cheats.erase(cheats.begin() + prevSize, cheats.end());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void CheatManager::saveCheatFile(const std::string& filename)
|
||||
|
|
Loading…
Reference in New Issue