Skip to content

Commit

Permalink
Qt: Fix possible game settings save error with sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Dec 5, 2024
1 parent 0c7636b commit ea63266
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/duckstation-qt/qthost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,16 @@ bool QtHost::SaveGameSettings(SettingsInterface* sif, bool delete_if_empty)
INISettingsInterface* ini = static_cast<INISettingsInterface*>(sif);
Error error;


// if there's no keys, just toss the whole thing out
if (delete_if_empty && ini->IsEmpty())
{
INFO_LOG("Removing empty gamesettings ini {}", Path::GetFileName(ini->GetFileName()));

// grab the settings lock while we're writing the file, that way the CPU thread doesn't try
// to read it at the same time.
const auto lock = Host::GetSettingsLock();

if (FileSystem::FileExists(ini->GetFileName().c_str()) &&
!FileSystem::DeleteFile(ini->GetFileName().c_str(), &error))
{
Expand All @@ -243,6 +249,9 @@ bool QtHost::SaveGameSettings(SettingsInterface* sif, bool delete_if_empty)
// clean unused sections, stops the file being bloated
sif->RemoveEmptySections();

// see above
const auto lock = Host::GetSettingsLock();

if (!sif->Save(&error))
{
Host::ReportErrorAsync(
Expand Down

0 comments on commit ea63266

Please # to comment.