[GH-ISSUE #1669] Save option settings on close #569

Closed
opened 2026-02-27 21:06:57 +03:00 by kerem · 5 comments
Owner

Originally created by @DanielSvoboda on GitHub (Dec 5, 2024).
Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/1669

In the two codes below, you can see that when you close the emulator, the settings are saved.
This means that even when you press Cancel in the settings menu, the settings will be saved.

I had tried to adjust this in the AutoUpdater PR, but I removed this attempt because it had nothing to do with that PR.
If I'm not mistaken this happens to save the screen position when closing...

https://github.com/shadps4-emu/shadPS4/blob/main/src/emulator.cpp#L100

Emulator::~Emulator() {
    const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
    Config::save(config_dir / "config.toml");
}

https://github.com/shadps4-emu/shadPS4/blob/main/src/qt_gui/main_window.cpp#L38

MainWindow::~MainWindow() {
    SaveWindowState();
    const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
    Config::save(config_dir / "config.toml");
}

https://github.com/user-attachments/assets/c58aa35b-9650-4828-8e25-0383dd3d84b1

Originally created by @DanielSvoboda on GitHub (Dec 5, 2024). Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/1669 In the two codes below, you can see that when you close the emulator, the settings are saved. This means that even when you press Cancel in the settings menu, the settings will be saved. I had tried to adjust this in the AutoUpdater PR, but I removed this attempt because it had nothing to do with that PR. If I'm not mistaken this happens to save the screen position when closing... https://github.com/shadps4-emu/shadPS4/blob/main/src/emulator.cpp#L100 ```cpp Emulator::~Emulator() { const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); Config::save(config_dir / "config.toml"); } ``` ---- https://github.com/shadps4-emu/shadPS4/blob/main/src/qt_gui/main_window.cpp#L38 ```cpp MainWindow::~MainWindow() { SaveWindowState(); const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); Config::save(config_dir / "config.toml"); } ``` ---- https://github.com/user-attachments/assets/c58aa35b-9650-4828-8e25-0383dd3d84b1
kerem closed this issue 2026-02-27 21:06:57 +03:00
Author
Owner

@rainmakerv3 commented on GitHub (Dec 6, 2024):

I looked into this , and it seems there is also a related issue is actually not just caused by the Emulator or Mainwindow destructors mentioned above, but also because the function loading the values for widgets in settings_dialog.cpp uses the values currently in memory rather the values written to the config file.

Even after removing the function call to config::save in each destructor (there should probably be another function saving just window dimensions and such), the issue will still happen if you close and reopen the settings dialog after changing a setting

https://github.com/user-attachments/assets/8eb6fcc3-a67e-4ef6-aa22-cea5a59f3f19

I don't know if there is a better solution for this, but for example changing this in https://github.com/shadps4-emu/shadPS4/blob/main/src/qt_gui/settings_dialog.cpp#L323:

ui->consoleLanguageComboBox->setCurrentIndex(
    std::distance(
        languageIndexes.begin(),
        std::find(languageIndexes.begin(), languageIndexes.end(), Config::GetLanguage())) %
    languageIndexes.size());

to this:

ui->consoleLanguageComboBox->setCurrentIndex(
std::distance(
languageIndexes.begin(),
std::find(languageIndexes.begin(), languageIndexes.end(), toml::find_or(data, "Settings", "consoleLanguage", 6))) %
languageIndexes.size());

(plus the toml parsing code)

solves the issue as per my testing. I have a sample build here (I only touched the console language setting): https://github.com/rainmakerv3/shadPS4/actions/runs/12199176835

https://github.com/user-attachments/assets/69e117bf-f66b-41b6-9312-e4d559291ec4

Let me know if you think this is an acceptable solution, so I can complete it and PR it.

<!-- gh-comment-id:2522958146 --> @rainmakerv3 commented on GitHub (Dec 6, 2024): I looked into this , and it seems there is also a related issue is actually not just caused by the Emulator or Mainwindow destructors mentioned above, but also because the function loading the values for widgets in settings_dialog.cpp uses the values currently in memory rather the values written to the config file. Even after removing the function call to config::save in each destructor (there should probably be another function saving just window dimensions and such), the issue will still happen if you close and reopen the settings dialog after changing a setting https://github.com/user-attachments/assets/8eb6fcc3-a67e-4ef6-aa22-cea5a59f3f19 I don't know if there is a better solution for this, but for example changing this in https://github.com/shadps4-emu/shadPS4/blob/main/src/qt_gui/settings_dialog.cpp#L323: ui->consoleLanguageComboBox->setCurrentIndex( std::distance( languageIndexes.begin(), std::find(languageIndexes.begin(), languageIndexes.end(), Config::GetLanguage())) % languageIndexes.size()); to this: ui->consoleLanguageComboBox->setCurrentIndex( std::distance( languageIndexes.begin(), std::find(languageIndexes.begin(), languageIndexes.end(), toml::find_or<int>(data, "Settings", "consoleLanguage", 6))) % languageIndexes.size()); (plus the toml parsing code) solves the issue as per my testing. I have a sample build here (I only touched the console language setting): https://github.com/rainmakerv3/shadPS4/actions/runs/12199176835 https://github.com/user-attachments/assets/69e117bf-f66b-41b6-9312-e4d559291ec4 Let me know if you think this is an acceptable solution, so I can complete it and PR it.
Author
Owner

@Hermiten commented on GitHub (Dec 6, 2024):

New PR is always welcome and they can review it more easily than here :)

<!-- gh-comment-id:2523406772 --> @Hermiten commented on GitHub (Dec 6, 2024): New PR is always welcome and they can review it more easily than here :)
Author
Owner

@rainmakerv3 commented on GitHub (Dec 7, 2024):

EDIT: the issue I found regarding the Discord RPC setting was fixed in a recent commit

I am currently working on a PR proposing a fix for the other issues, hopefully I can submit it by tomorrow

<!-- gh-comment-id:2525046131 --> @rainmakerv3 commented on GitHub (Dec 7, 2024): EDIT: the issue I found regarding the Discord RPC setting was fixed in a recent commit I am currently working on a PR proposing a fix for the other issues, hopefully I can submit it by tomorrow
Author
Owner

@DanielSvoboda commented on GitHub (Dec 12, 2024):

After PR-1747 the save was fixed, but I'm experiencing other problems, I don't know if it was caused by this PR. I'm not able to add a new game folder. When I click apply it's not adding my gamesConfig2 folder, it's re-adding gamesConfig, it's very strange as you can see in the video.

https://github.com/user-attachments/assets/25997eaa-391f-4bec-ac1b-6bf7576802ca

<!-- gh-comment-id:2540090639 --> @DanielSvoboda commented on GitHub (Dec 12, 2024): After [PR-1747](https://github.com/shadps4-emu/shadPS4/pull/1747) the save was fixed, but I'm experiencing other problems, I don't know if it was caused by this PR. I'm not able to add a new game folder. When I click apply it's not adding my gamesConfig2 folder, it's re-adding gamesConfig, it's very strange as you can see in the video. https://github.com/user-attachments/assets/25997eaa-391f-4bec-ac1b-6bf7576802ca
Author
Owner

@rainmakerv3 commented on GitHub (Dec 13, 2024):

yeah this was my fault sorry :depair: should be fixed by https://github.com/shadps4-emu/shadPS4/pull/1761

<!-- gh-comment-id:2540801577 --> @rainmakerv3 commented on GitHub (Dec 13, 2024): yeah this was my fault sorry :depair: should be fixed by https://github.com/shadps4-emu/shadPS4/pull/1761
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#569
No description provided.