aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhi <7350221+PhiZero@users.noreply.github.com>2023-01-21 01:36:57 +0100
committerGitHub <noreply@github.com>2023-01-21 01:36:57 +0100
commitdd7a924596ff5925baa8b7f3ec85ceda8cb1cd8a (patch)
treeb87af6607310efd6e6c9b2f87f9931567506faaf
parenta76eaf9a9ab042e05841d1369c2e466a4f63a48f (diff)
Catch Profile.json parse to prevent crash on launch (#3393)1.1.579
* Catch Profile.json parse to prevent crash on launch * Update Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> Co-authored-by: PhiZero <wolkan.craanen@gmail.com> Co-authored-by: Ac_K <Acoustik666@gmail.com>
-rw-r--r--Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs23
1 files changed, 17 insertions, 6 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs b/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs
index 44ef3f33..3bd0e2da 100644
--- a/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs
+++ b/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs
@@ -1,5 +1,7 @@
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Utilities;
+using Ryujinx.Common.Logging;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
@@ -43,16 +45,25 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
if (File.Exists(_profilesJsonPath))
{
- ProfilesJson profilesJson = JsonHelper.DeserializeFromFile<ProfilesJson>(_profilesJsonPath);
-
- foreach (var profile in profilesJson.Profiles)
+ try
{
- UserProfile addedProfile = new UserProfile(new UserId(profile.UserId), profile.Name, profile.Image, profile.LastModifiedTimestamp);
+ ProfilesJson profilesJson = JsonHelper.DeserializeFromFile<ProfilesJson>(_profilesJsonPath);
+
+ foreach (var profile in profilesJson.Profiles)
+ {
+ UserProfile addedProfile = new UserProfile(new UserId(profile.UserId), profile.Name, profile.Image, profile.LastModifiedTimestamp);
+
+ profiles.AddOrUpdate(profile.UserId, addedProfile, (key, old) => addedProfile);
+ }
- profiles.AddOrUpdate(profile.UserId, addedProfile, (key, old) => addedProfile);
+ LastOpened = new UserId(profilesJson.LastOpened);
}
+ catch (Exception e)
+ {
+ Logger.Error?.Print(LogClass.Application, $"Failed to parse {_profilesJsonPath}: {e.Message} Loading default profile!");
- LastOpened = new UserId(profilesJson.LastOpened);
+ LastOpened = AccountManager.DefaultUserId;
+ }
}
else
{