Skip to content

Commit

Permalink
Qt: Fix legacy cht file clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Nov 3, 2024
1 parent ac19768 commit 88147d8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/duckstation-qt/gamecheatsettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void GameCheatSettingsWidget::checkForMasterDisable()
if (m_dialog->getSettingsInterface()->GetBoolValue("Cheats", "EnableCheats", false) || m_master_enable_ignored)
return;

QMessageBox mbox;
QMessageBox mbox(this);
mbox.setIcon(QMessageBox::Warning);
mbox.setWindowTitle(tr("Confirm Cheat Enable"));
mbox.setWindowIcon(QtHost::GetAppIcon());
Expand Down Expand Up @@ -626,15 +626,15 @@ void GameCheatSettingsWidget::onClearClicked()
disableAllCheats();

Error error;
std::string path = Cheats::GetChtFilename(m_dialog->getGameSerial(), std::nullopt, true);
std::string path = Cheats::GetChtFilename(m_dialog->getGameSerial(), m_dialog->getGameHash(), true);
if (FileSystem::FileExists(path.c_str()))
{
if (!FileSystem::DeleteFile(path.c_str(), &error))
ERROR_LOG("Failed to remove cht file '{}': {}", Path::GetFileName(path), error.GetDescription());
}

// check for a non-hashed path and remove that too
path = Cheats::GetChtFilename(m_dialog->getGameSerial(), m_dialog->getGameHash(), true);
path = Cheats::GetChtFilename(m_dialog->getGameSerial(), std::nullopt, true);
if (FileSystem::FileExists(path.c_str()))
{
if (!FileSystem::DeleteFile(path.c_str(), &error))
Expand All @@ -644,7 +644,7 @@ void GameCheatSettingsWidget::onClearClicked()
// and a legacy cht file with the game title
if (const std::string& title = m_dialog->getGameTitle(); !title.empty())
{
path = Path::Combine(EmuFolders::Cheats, Path::SanitizeFileName(title));
path = fmt::format("{}" FS_OSPATH_SEPARATOR_STR "{}.cht", EmuFolders::Cheats, Path::SanitizeFileName(title));
if (FileSystem::FileExists(path.c_str()))
{
if (!FileSystem::DeleteFile(path.c_str(), &error))
Expand Down

0 comments on commit 88147d8

Please sign in to comment.