Qt: Fix possible game settings save error with sliders
This commit is contained in:
parent
0c7636b3c3
commit
ea632665c1
|
@ -223,10 +223,16 @@ bool QtHost::SaveGameSettings(SettingsInterface* sif, bool delete_if_empty)
|
||||||
INISettingsInterface* ini = static_cast<INISettingsInterface*>(sif);
|
INISettingsInterface* ini = static_cast<INISettingsInterface*>(sif);
|
||||||
Error error;
|
Error error;
|
||||||
|
|
||||||
|
|
||||||
// if there's no keys, just toss the whole thing out
|
// if there's no keys, just toss the whole thing out
|
||||||
if (delete_if_empty && ini->IsEmpty())
|
if (delete_if_empty && ini->IsEmpty())
|
||||||
{
|
{
|
||||||
INFO_LOG("Removing empty gamesettings ini {}", Path::GetFileName(ini->GetFileName()));
|
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()) &&
|
if (FileSystem::FileExists(ini->GetFileName().c_str()) &&
|
||||||
!FileSystem::DeleteFile(ini->GetFileName().c_str(), &error))
|
!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
|
// clean unused sections, stops the file being bloated
|
||||||
sif->RemoveEmptySections();
|
sif->RemoveEmptySections();
|
||||||
|
|
||||||
|
// see above
|
||||||
|
const auto lock = Host::GetSettingsLock();
|
||||||
|
|
||||||
if (!sif->Save(&error))
|
if (!sif->Save(&error))
|
||||||
{
|
{
|
||||||
Host::ReportErrorAsync(
|
Host::ReportErrorAsync(
|
||||||
|
|
Loading…
Reference in New Issue