From 9d7dc97c3e14302d12f02fdf77c90ef58d7ce044 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 8 Mar 2020 15:25:20 -0700 Subject: [PATCH] Android: Reload game config on storage permission. Before, we were saving out the global values on top of the game config while loading them. We seem to get the storage permission event twice sometimes, which is what causes this to happen after we've already loaded the game config. --- Core/Config.cpp | 11 +++++++++-- Core/Config.h | 2 ++ UI/NativeApp.cpp | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index d8e03cf5ab..9a4e54743a 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1114,6 +1114,12 @@ std::map> GetLangValuesMapping() { return langValuesMapping; } +void Config::Reload() { + reload_ = true; + Load(); + reload_ = false; +} + void Config::Load(const char *iniFileName, const char *controllerIniFilename) { const bool useIniFilename = iniFileName != nullptr && strlen(iniFileName) > 0; iniFilename_ = FindConfigFile(useIniFilename ? iniFileName : "ppsspp.ini"); @@ -1489,7 +1495,8 @@ bool Config::hasGameConfig(const std::string &pGameId) { } void Config::changeGameSpecific(const std::string &pGameId, const std::string &title) { - Save("changeGameSpecific"); + if (!reload_) + Save("changeGameSpecific"); gameId_ = pGameId; gameIdTitle_ = title; bGameSpecific = !pGameId.empty(); @@ -1568,7 +1575,7 @@ bool Config::loadGameConfig(const std::string &pGameId, const std::string &title } void Config::unloadGameConfig() { - if (bGameSpecific){ + if (bGameSpecific) { changeGameSpecific(); IniFile iniFile; diff --git a/Core/Config.h b/Core/Config.h index 5a0777b0a3..4e354639bc 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -452,6 +452,7 @@ public: void Load(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr); void Save(const char *saveReason); + void Reload(); void RestoreDefaults(); //per game config managment, should maybe be in it's own class @@ -490,6 +491,7 @@ protected: void LoadStandardControllerIni(); private: + bool reload_ = false; std::string gameId_; std::string gameIdTitle_; std::string iniFilename_; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 7cf11f7c29..3334120685 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1174,7 +1174,7 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { // and I can't risk it before 1.9.0. int gpuBackend = g_Config.iGPUBackend; ILOG("Reloading config after storage permission grant."); - g_Config.Load(); + g_Config.Reload(); PostLoadConfig(); g_Config.iGPUBackend = gpuBackend; }