diff --git a/CustomizePlus/Api/CustomizePlusIpc.Profile.cs b/CustomizePlus/Api/CustomizePlusIpc.Profile.cs index ebaa260..261ea4a 100644 --- a/CustomizePlus/Api/CustomizePlusIpc.Profile.cs +++ b/CustomizePlus/Api/CustomizePlusIpc.Profile.cs @@ -145,6 +145,7 @@ public partial class CustomizePlusIpc [EzIPC("Profile.SetTemporaryProfileOnCharacter")] private (int, Guid?) SetTemporaryProfileOnCharacter(Character character, string profileJson) { + //todo: do not allow to set temporary profile on reserved actors (examine, etc) if (character == null) return ((int)ErrorCode.InvalidCharacter, null); diff --git a/CustomizePlus/Profiles/ProfileManager.cs b/CustomizePlus/Profiles/ProfileManager.cs index 5e7df23..db2b976 100644 --- a/CustomizePlus/Profiles/ProfileManager.cs +++ b/CustomizePlus/Profiles/ProfileManager.cs @@ -583,9 +583,18 @@ public class ProfileManager : IDisposable var profile = armature!.Profile; + if (!profile.IsTemporary) + return; + + //Do not proceed unless there are no armatures left + //because this might be the case of examine window actor being gone. + //Profiles for those are shared with the original actor. + if (profile.Armatures.Count > 0) + return; + //todo: TemporaryProfileDeleted ends up calling this again, fix this. //Profiles.Remove check won't allow for infinite loop but this isn't good anyway - if (!profile.IsTemporary || !Profiles.Remove(profile)) + if (!Profiles.Remove(profile)) return; _logger.Debug($"ProfileManager.OnArmatureChange: Removed unused temporary profile for {profile.CharacterName}");