Qt: Fix possible game settings save error with sliders

This commit is contained in:
Stenzek 2024-12-05 18:57:35 +10:00
parent 0c7636b3c3
commit ea632665c1
No known key found for this signature in database
1 changed files with 9 additions and 0 deletions

View File

@ -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))
{
@ -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(