diff options
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 19 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.h | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_profile_manager.cpp | 4 |
3 files changed, 21 insertions, 3 deletions
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 5542d6cbc..683f44e27 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -61,9 +61,7 @@ ProfileManager::ProfileManager() { | |||
| 61 | OpenUser(*GetUser(current)); | 61 | OpenUser(*GetUser(current)); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | ProfileManager::~ProfileManager() { | 64 | ProfileManager::~ProfileManager() = default; |
| 65 | WriteUserSaveFile(); | ||
| 66 | } | ||
| 67 | 65 | ||
| 68 | /// After a users creation it needs to be "registered" to the system. AddToProfiles handles the | 66 | /// After a users creation it needs to be "registered" to the system. AddToProfiles handles the |
| 69 | /// internal management of the users profiles | 67 | /// internal management of the users profiles |
| @@ -113,6 +111,8 @@ Result ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& username) | |||
| 113 | return ERROR_USER_ALREADY_EXISTS; | 111 | return ERROR_USER_ALREADY_EXISTS; |
| 114 | } | 112 | } |
| 115 | 113 | ||
| 114 | is_save_needed = true; | ||
| 115 | |||
| 116 | return AddUser({ | 116 | return AddUser({ |
| 117 | .user_uuid = uuid, | 117 | .user_uuid = uuid, |
| 118 | .username = username, | 118 | .username = username, |
| @@ -326,6 +326,9 @@ bool ProfileManager::RemoveUser(UUID uuid) { | |||
| 326 | profiles[*index] = ProfileInfo{}; | 326 | profiles[*index] = ProfileInfo{}; |
| 327 | std::stable_partition(profiles.begin(), profiles.end(), | 327 | std::stable_partition(profiles.begin(), profiles.end(), |
| 328 | [](const ProfileInfo& profile) { return profile.user_uuid.IsValid(); }); | 328 | [](const ProfileInfo& profile) { return profile.user_uuid.IsValid(); }); |
| 329 | |||
| 330 | is_save_needed = true; | ||
| 331 | |||
| 329 | return true; | 332 | return true; |
| 330 | } | 333 | } |
| 331 | 334 | ||
| @@ -340,6 +343,8 @@ bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { | |||
| 340 | profile.username = profile_new.username; | 343 | profile.username = profile_new.username; |
| 341 | profile.creation_time = profile_new.timestamp; | 344 | profile.creation_time = profile_new.timestamp; |
| 342 | 345 | ||
| 346 | is_save_needed = true; | ||
| 347 | |||
| 343 | return true; | 348 | return true; |
| 344 | } | 349 | } |
| 345 | 350 | ||
| @@ -348,6 +353,7 @@ bool ProfileManager::SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& | |||
| 348 | const auto index = GetUserIndex(uuid); | 353 | const auto index = GetUserIndex(uuid); |
| 349 | if (index.has_value() && SetProfileBase(uuid, profile_new)) { | 354 | if (index.has_value() && SetProfileBase(uuid, profile_new)) { |
| 350 | profiles[*index].data = data_new; | 355 | profiles[*index].data = data_new; |
| 356 | is_save_needed = true; | ||
| 351 | return true; | 357 | return true; |
| 352 | } | 358 | } |
| 353 | 359 | ||
| @@ -391,6 +397,10 @@ void ProfileManager::ParseUserSaveFile() { | |||
| 391 | } | 397 | } |
| 392 | 398 | ||
| 393 | void ProfileManager::WriteUserSaveFile() { | 399 | void ProfileManager::WriteUserSaveFile() { |
| 400 | if (!is_save_needed) { | ||
| 401 | return; | ||
| 402 | } | ||
| 403 | |||
| 394 | ProfileDataRaw raw{}; | 404 | ProfileDataRaw raw{}; |
| 395 | 405 | ||
| 396 | for (std::size_t i = 0; i < MAX_USERS; ++i) { | 406 | for (std::size_t i = 0; i < MAX_USERS; ++i) { |
| @@ -423,7 +433,10 @@ void ProfileManager::WriteUserSaveFile() { | |||
| 423 | if (!save.IsOpen() || !save.SetSize(sizeof(ProfileDataRaw)) || !save.WriteObject(raw)) { | 433 | if (!save.IsOpen() || !save.SetSize(sizeof(ProfileDataRaw)) || !save.WriteObject(raw)) { |
| 424 | LOG_WARNING(Service_ACC, "Failed to write save data to file... No changes to user data " | 434 | LOG_WARNING(Service_ACC, "Failed to write save data to file... No changes to user data " |
| 425 | "made in current session will be saved."); | 435 | "made in current session will be saved."); |
| 436 | return; | ||
| 426 | } | 437 | } |
| 438 | |||
| 439 | is_save_needed = false; | ||
| 427 | } | 440 | } |
| 428 | 441 | ||
| 429 | }; // namespace Service::Account | 442 | }; // namespace Service::Account |
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index 900e32200..e21863e64 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h | |||
| @@ -103,6 +103,7 @@ private: | |||
| 103 | std::optional<std::size_t> AddToProfiles(const ProfileInfo& profile); | 103 | std::optional<std::size_t> AddToProfiles(const ProfileInfo& profile); |
| 104 | bool RemoveProfileAtIndex(std::size_t index); | 104 | bool RemoveProfileAtIndex(std::size_t index); |
| 105 | 105 | ||
| 106 | bool is_save_needed{}; | ||
| 106 | std::array<ProfileInfo, MAX_USERS> profiles{}; | 107 | std::array<ProfileInfo, MAX_USERS> profiles{}; |
| 107 | std::array<ProfileInfo, MAX_USERS> stored_opened_profiles{}; | 108 | std::array<ProfileInfo, MAX_USERS> stored_opened_profiles{}; |
| 108 | std::size_t user_count{}; | 109 | std::size_t user_count{}; |
diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index fa5f383d6..12a04b9a0 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp | |||
| @@ -205,6 +205,7 @@ void ConfigureProfileManager::AddUser() { | |||
| 205 | 205 | ||
| 206 | const auto uuid = Common::UUID::MakeRandom(); | 206 | const auto uuid = Common::UUID::MakeRandom(); |
| 207 | profile_manager.CreateNewUser(uuid, username.toStdString()); | 207 | profile_manager.CreateNewUser(uuid, username.toStdString()); |
| 208 | profile_manager.WriteUserSaveFile(); | ||
| 208 | 209 | ||
| 209 | item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)}); | 210 | item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)}); |
| 210 | } | 211 | } |
| @@ -228,6 +229,7 @@ void ConfigureProfileManager::RenameUser() { | |||
| 228 | std::copy(username_std.begin(), username_std.end(), profile.username.begin()); | 229 | std::copy(username_std.begin(), username_std.end(), profile.username.begin()); |
| 229 | 230 | ||
| 230 | profile_manager.SetProfileBase(*uuid, profile); | 231 | profile_manager.SetProfileBase(*uuid, profile); |
| 232 | profile_manager.WriteUserSaveFile(); | ||
| 231 | 233 | ||
| 232 | item_model->setItem( | 234 | item_model->setItem( |
| 233 | user, 0, | 235 | user, 0, |
| @@ -256,6 +258,8 @@ void ConfigureProfileManager::DeleteUser(const Common::UUID& uuid) { | |||
| 256 | return; | 258 | return; |
| 257 | } | 259 | } |
| 258 | 260 | ||
| 261 | profile_manager.WriteUserSaveFile(); | ||
| 262 | |||
| 259 | item_model->removeRows(tree_view->currentIndex().row(), 1); | 263 | item_model->removeRows(tree_view->currentIndex().row(), 1); |
| 260 | tree_view->clearSelection(); | 264 | tree_view->clearSelection(); |
| 261 | 265 | ||