From 1c278974a87b9a94edd4d8b08317071bd36823bf Mon Sep 17 00:00:00 2001 From: t895 Date: Wed, 3 Jan 2024 21:38:29 -0500 Subject: [PATCH 1/3] android: Don't save settings on config destruction Android doesn't have a proper way of destroying its config object so it's best to stick to the built-in methods to control saving config --- src/android/app/src/main/jni/android_config.cpp | 6 ------ src/android/app/src/main/jni/android_config.h | 1 - 2 files changed, 7 deletions(-) diff --git a/src/android/app/src/main/jni/android_config.cpp b/src/android/app/src/main/jni/android_config.cpp index c86aa1c39..08aed3216 100644 --- a/src/android/app/src/main/jni/android_config.cpp +++ b/src/android/app/src/main/jni/android_config.cpp @@ -14,12 +14,6 @@ AndroidConfig::AndroidConfig(const std::string& config_name, ConfigType config_t } } -AndroidConfig::~AndroidConfig() { - if (global) { - AndroidConfig::SaveAllValues(); - } -} - void AndroidConfig::ReloadAllValues() { Reload(); ReadAndroidValues(); diff --git a/src/android/app/src/main/jni/android_config.h b/src/android/app/src/main/jni/android_config.h index d83852de9..693e1e3f0 100644 --- a/src/android/app/src/main/jni/android_config.h +++ b/src/android/app/src/main/jni/android_config.h @@ -9,7 +9,6 @@ class AndroidConfig final : public Config { public: explicit AndroidConfig(const std::string& config_name = "config", ConfigType config_type = ConfigType::GlobalConfig); - ~AndroidConfig() override; void ReloadAllValues() override; void SaveAllValues() override; From fa04dea7c4f0d5dba86cdec23d6e8262752983e9 Mon Sep 17 00:00:00 2001 From: t895 Date: Wed, 3 Jan 2024 22:16:54 -0500 Subject: [PATCH 2/3] frontend_common: config: Only write setting related to opened config file If we tried to write a switchable setting to config that was not using global in the global config instance, we could write the per-game setting accidentally. This ensures that we always use the global setting for global config and the currently applied setting for custom config. --- src/frontend_common/config.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frontend_common/config.cpp b/src/frontend_common/config.cpp index 51576b4ee..678e27ef8 100644 --- a/src/frontend_common/config.cpp +++ b/src/frontend_common/config.cpp @@ -894,9 +894,10 @@ void Config::WriteSettingGeneric(const Settings::BasicSetting* const setting) { WriteBooleanSetting(std::string(key).append("\\use_global"), setting->UsingGlobal()); } if (global || !setting->UsingGlobal()) { + auto value = global ? setting->ToStringGlobal() : setting->ToString(); WriteBooleanSetting(std::string(key).append("\\default"), - setting->ToString() == setting->DefaultToString()); - WriteStringSetting(key, setting->ToString()); + value == setting->DefaultToString()); + WriteStringSetting(key, value); } } else if (global) { WriteBooleanSetting(std::string(key).append("\\default"), From 39d28a51317bbb352cbd51f9e019011b7fd63d9d Mon Sep 17 00:00:00 2001 From: t895 Date: Wed, 3 Jan 2024 21:40:10 -0500 Subject: [PATCH 3/3] android: Save global config synchronously in onCloseGameFoldersFragment Could cause multiple global saves at once that went untracked previously --- .../src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt index d19f20dc2..5ae05b5cc 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt @@ -167,13 +167,14 @@ class GamesViewModel : ViewModel() { } } - fun onCloseGameFoldersFragment() = + fun onCloseGameFoldersFragment() { + NativeConfig.saveGlobalConfig() viewModelScope.launch { withContext(Dispatchers.IO) { - NativeConfig.saveGlobalConfig() getGameDirs(true) } } + } private fun getGameDirs(reloadList: Boolean = false) { val gameDirs = NativeConfig.getGameDirs()