From d91f7062066136d5a4275444091692df077515dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 23 Feb 2019 10:49:49 +0100 Subject: [PATCH] Log why the config is being saved (we seem to do it a bit much at times) --- Core/Config.cpp | 8 ++++---- Core/Config.h | 2 +- Qt/QtMain.cpp | 2 +- UI/ComboKeyMappingScreen.cpp | 4 ++-- UI/ControlMappingScreen.cpp | 6 ++---- UI/DisplayLayoutScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 10 +++++----- UI/MainScreen.cpp | 2 +- UI/NativeApp.cpp | 6 +++--- UI/ReportScreen.cpp | 2 +- UI/TouchControlLayoutScreen.cpp | 2 +- UI/TouchControlVisibilityScreen.cpp | 4 ++-- Windows/EmuThread.cpp | 4 ++-- Windows/GPU/D3D11Context.cpp | 4 ++-- Windows/GPU/WindowsGLContext.cpp | 2 +- Windows/MainWindowMenu.cpp | 8 ++++---- 16 files changed, 33 insertions(+), 35 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index fc2026c9bc..9ae911e268 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1109,7 +1109,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { } } -void Config::Save() { +void Config::Save(const char *saveReason) { if (jitForcedOff) { // if JIT has been forced off, we don't want to screw up the user's ppsspp.ini g_Config.iCpuCore = (int)CPUCore::JIT; @@ -1162,11 +1162,11 @@ void Config::Save() { LogManager::GetInstance()->SaveConfig(log); if (!iniFile.Save(iniFilename_.c_str())) { - ERROR_LOG(LOADER, "Error saving config - can't write ini '%s'", iniFilename_.c_str()); + ERROR_LOG(LOADER, "Error saving config (%s)- can't write ini '%s'", saveReason, iniFilename_.c_str()); System_SendMessage("toast", "Failed to save settings!\nCheck permissions, or try to restart the device."); return; } - INFO_LOG(LOADER, "Config saved: '%s'", iniFilename_.c_str()); + INFO_LOG(LOADER, "Config saved (%s): '%s'", saveReason, iniFilename_.c_str()); if (!bGameSpecific) //otherwise we already did this in saveGameConfig() { @@ -1353,7 +1353,7 @@ bool Config::hasGameConfig(const std::string &pGameId) { } void Config::changeGameSpecific(const std::string &pGameId) { - Save(); + Save("changeGameSpecific"); gameId_ = pGameId; bGameSpecific = !pGameId.empty(); } diff --git a/Core/Config.h b/Core/Config.h index ce8ad14588..a45080ff0e 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -410,7 +410,7 @@ public: std::string dismissedVersion; void Load(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr); - void Save(); + void Save(const char *saveReason); void RestoreDefaults(); //per game config managment, should maybe be in it's own class diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 3e18b54028..e6e311f0e0 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -405,7 +405,7 @@ bool MainUI::event(QEvent *e) { if (QFile::exists(fileName)) { QDir newPath; g_Config.currentDirectory = newPath.filePath(fileName).toStdString(); - g_Config.Save(); + g_Config.Save("browseFileEvent"); NativeMessageReceived("boot", fileName.toStdString().c_str()); } diff --git a/UI/ComboKeyMappingScreen.cpp b/UI/ComboKeyMappingScreen.cpp index a32d480f76..7860a49710 100644 --- a/UI/ComboKeyMappingScreen.cpp +++ b/UI/ComboKeyMappingScreen.cpp @@ -44,7 +44,7 @@ void Combo_keyScreen::CreateViews() { static const int comboKeyImages[5] = { I_1, I_2, I_3, I_4, I_5, }; - + comboselect = new ChoiceStrip(ORIENT_VERTICAL, new AnchorLayoutParams(10, 10, NONE, NONE)); comboselect->SetSpacing(10); for (int i = 0; i < 5; i++) { @@ -169,7 +169,7 @@ void Combo_keyScreen::onFinish(DialogResult result) { g_Config.iCombokey4 = arrayToInt(array); break; } - g_Config.Save(); + g_Config.Save("Combo_keyScreen::onFInish"); } UI::EventReturn Combo_keyScreen::ChoiceEventHandler::onChoiceClick(UI::EventParams &e){ diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 0612cad540..67cbca1775 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -431,8 +431,8 @@ class JoystickHistoryView : public UI::InertView { public: JoystickHistoryView(int xAxis, int xDevice, int xDir, int yAxis, int yDevice, int yDir, UI::LayoutParams *layoutParams = nullptr) : UI::InertView(layoutParams), - xAxis_(xAxis), xDevice_(xDevice), xDir_(xDir), - yAxis_(yAxis), yDevice_(yDevice), yDir_(yDir), + xAxis_(xAxis), xDir_(xDir), + yAxis_(yAxis), yDir_(yDir), curX_(0.0f), curY_(0.0f), maxCount_(500) {} void Draw(UIContext &dc) override; @@ -455,10 +455,8 @@ private: }; int xAxis_; - int xDevice_; int xDir_; int yAxis_; - int yDevice_; int yDir_; float curX_; diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 0ba1901811..3f5f14ef13 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -173,7 +173,7 @@ void DisplayLayoutScreen::resized() { } void DisplayLayoutScreen::onFinish(DialogResult reason) { - g_Config.Save(); + g_Config.Save("DisplayLayoutScreen::onFinish"); } UI::EventReturn DisplayLayoutScreen::OnCenter(UI::EventParams &e) { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index c04cc88602..cb1c80fdc1 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1065,7 +1065,7 @@ void GameSettingsScreen::onFinish(DialogResult result) { Reporting::Enable(enableReports_, "report.ppsspp.org"); Reporting::UpdateConfig(); - g_Config.Save(); + g_Config.Save("GameSettingsScreen::onFinish"); if (editThenRestore_) { g_Config.unloadGameConfig(); } @@ -1137,7 +1137,7 @@ void GameSettingsScreen::CallbackMemstickFolder(bool yes) { writeDataToFile(true, pendingMemstickFolder_.c_str(), pendingMemstickFolder_.size(), memstickDirFile.c_str()); // Save so the settings, at least, are transferred. g_Config.memStickDirectory = pendingMemstickFolder_ + "/"; - g_Config.Save(); + g_Config.Save("MemstickPathChanged"); screenManager()->RecreateAllViews(); } } @@ -1149,7 +1149,7 @@ void GameSettingsScreen::CallbackRenderingBackend(bool yes) { if (yes) { // Extra save here to make sure the choice really gets saved even if there are shutdown bugs in // the GPU backend code. - g_Config.Save(); + g_Config.Save("GameSettingsScreen::RenderingBackendYes"); System_SendMessage("graphics_restart", ""); } else { g_Config.iGPUBackend = (int)GetGPUBackend(); @@ -1162,7 +1162,7 @@ void GameSettingsScreen::CallbackRenderingDevice(bool yes) { if (yes) { // Extra save here to make sure the choice really gets saved even if there are shutdown bugs in // the GPU backend code. - g_Config.Save(); + g_Config.Save("GameSettingsScreen::RenderingDeviceYes"); System_SendMessage("graphics_restart", ""); } else { std::string *deviceNameSetting = GPUDeviceNameSetting(); @@ -1397,7 +1397,7 @@ void DeveloperToolsScreen::CreateViews() { } void DeveloperToolsScreen::onFinish(DialogResult result) { - g_Config.Save(); + g_Config.Save("DeveloperToolsScreen::onFinish"); } void GameSettingsScreen::CallbackRestoreDefaults(bool yes) { diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 8f1fb0044d..46b80d64be 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1199,7 +1199,7 @@ UI::EventReturn MainScreen::OnExit(UI::EventParams &e) { System_SendMessage("finish", ""); // However, let's make sure the config was saved, since it may not have been. - g_Config.Save(); + g_Config.Save("MainScreen::OnExit"); #ifdef __ANDROID__ #ifdef ANDROID_NDK_PROFILER diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index baa72bb9eb..38e94664e6 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -401,7 +401,7 @@ static void CheckFailedGPUBackends() { writeStringToFile(true, g_Config.sFailedGPUBackends, cache.c_str()); } else { // Just save immediately, since we have storage. - g_Config.Save(); + g_Config.Save("got storage permission"); } } @@ -415,7 +415,7 @@ static void ClearFailedGPUBackends() { if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) { File::Delete(GetSysDirectory(DIRECTORY_APP_CACHE) + "/FailedGraphicsBackends.txt"); } else { - g_Config.Save(); + g_Config.Save("clearFailedGPUBackends"); } } @@ -1292,7 +1292,7 @@ void NativeShutdown() { delete host; host = nullptr; #endif - g_Config.Save(); + g_Config.Save("NativeShutdown"); // Avoid shutting this down when restarting core. if (!restarting) diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index ae10ed1660..7901e92a44 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -330,7 +330,7 @@ EventReturn ReportScreen::HandleSubmit(EventParams &e) { if (Reporting::Enable(enableReporting_, "report.ppsspp.org")) { Reporting::UpdateConfig(); - g_Config.Save(); + g_Config.Save("ReportScreen::HandleSubmit"); } std::string filename = includeScreenshot_ ? screenshotFilename_ : ""; diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 77ca20d956..f75332be81 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -286,7 +286,7 @@ void TouchControlLayoutScreen::resized() { } void TouchControlLayoutScreen::onFinish(DialogResult reason) { - g_Config.Save(); + g_Config.Save("TouchControlLayoutScreen::onFinish"); } UI::EventReturn TouchControlLayoutScreen::OnVisibility(UI::EventParams &e) { diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 4e67d1cc5c..20c0407c8b 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -106,14 +106,14 @@ void TouchControlVisibilityScreen::CreateViews() { } choice->SetCentered(true); - + row->Add(choice); grid->Add(row); } } void TouchControlVisibilityScreen::onFinish(DialogResult result) { - g_Config.Save(); + g_Config.Save("TouchControlVisibilityScreen::onFinish"); } UI::EventReturn TouchControlVisibilityScreen::OnToggleAll(UI::EventParams &e) { diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 5a81b5ceb8..3e310bf7cb 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -159,7 +159,7 @@ void MainThreadFunc() { if (performingRestart) { // Okay, switching graphics didn't work out. Probably a driver bug - fallback to restart. // This happens on NVIDIA when switching OpenGL -> Vulkan. - g_Config.Save(); + g_Config.Save("switch_graphics_failed"); W32Util::ExitAndRestart(); } @@ -196,7 +196,7 @@ void MainThreadFunc() { g_Config.iGPUBackend = (int)nextBackend; // Clear this to ensure we try their selection. g_Config.sFailedGPUBackends.clear(); - g_Config.Save(); + g_Config.Save("save_graphics_fallback"); W32Util::ExitAndRestart(); } else { diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index 183a3d0529..2841c00387 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -145,10 +145,10 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) { std::wstring title = ConvertUTF8ToWString(err->T("D3D11InitializationError", "Direct3D 11 initialization error")); bool yes = IDYES == MessageBox(hWnd_, error.c_str(), title.c_str(), MB_ICONERROR | MB_YESNO); if (yes) { - // Change the config to D3D and restart. + // Change the config to D3D9 and restart. g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D9; g_Config.sFailedGPUBackends.clear(); - g_Config.Save(); + g_Config.Save("save_d3d9_fallback"); W32Util::ExitAndRestart(); } diff --git a/Windows/GPU/WindowsGLContext.cpp b/Windows/GPU/WindowsGLContext.cpp index 0701ffa4aa..e4851e6329 100644 --- a/Windows/GPU/WindowsGLContext.cpp +++ b/Windows/GPU/WindowsGLContext.cpp @@ -271,7 +271,7 @@ bool WindowsGLContext::InitFromRenderThread(std::string *error_message) { bool d3d9 = IDYES == MessageBox(hWnd_, whichD3D9.c_str(), title.c_str(), MB_YESNO); g_Config.iGPUBackend = d3d9 ? (int)GPUBackend::DIRECT3D9 : (int)GPUBackend::DIRECT3D11; g_Config.sFailedGPUBackends.clear(); - g_Config.Save(); + g_Config.Save("save_d3d11_fallback"); W32Util::ExitAndRestart(); } diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index b0a87829a7..b6ff2d0eac 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -759,25 +759,25 @@ namespace MainWindow { case ID_OPTIONS_DIRECT3D9: g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D9; - g_Config.Save(); + g_Config.Save("gpu_choice"); RestartApp(); break; case ID_OPTIONS_DIRECT3D11: g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D11; - g_Config.Save(); + g_Config.Save("gpu_choice"); RestartApp(); break; case ID_OPTIONS_OPENGL: g_Config.iGPUBackend = (int)GPUBackend::OPENGL; - g_Config.Save(); + g_Config.Save("gpu_choice"); RestartApp(); break; case ID_OPTIONS_VULKAN: g_Config.iGPUBackend = (int)GPUBackend::VULKAN; - g_Config.Save(); + g_Config.Save("gpu_choice"); RestartApp(); break;