Skip to content

Commit

Permalink
Log why the config is being saved (we seem to do it a bit much at times)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Feb 23, 2019
1 parent 24510b8 commit d91f706
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 35 deletions.
8 changes: 4 additions & 4 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ struct Config {
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
Expand Down
2 changes: 1 addition & 1 deletion Qt/QtMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions UI/ComboKeyMappingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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){
Expand Down
6 changes: 2 additions & 4 deletions UI/ControlMappingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -455,10 +455,8 @@ class JoystickHistoryView : public UI::InertView {
};

int xAxis_;
int xDevice_;
int xDir_;
int yAxis_;
int yDevice_;
int yDir_;

float curX_;
Expand Down
2 changes: 1 addition & 1 deletion UI/DisplayLayoutScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion UI/MainScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand All @@ -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");
}
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion UI/ReportScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_ : "";
Expand Down
2 changes: 1 addition & 1 deletion UI/TouchControlLayoutScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions UI/TouchControlVisibilityScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions Windows/EmuThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Windows/GPU/D3D11Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion Windows/GPU/WindowsGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
8 changes: 4 additions & 4 deletions Windows/MainWindowMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d91f706

Please sign in to comment.