From 076dab924fa21e67d28e88ee5a01601c532160a5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 27 Jan 2024 18:58:26 +0100 Subject: [PATCH] Reuse same list for warnings and exceptions. --- .../ModEditWindow.Models.MdlTab.cs | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs index b3c0cacd..37b9dfb5 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs @@ -28,8 +28,8 @@ public partial class ModEditWindow private bool _dirty; public bool PendingIo { get; private set; } - public List IoExceptions { get; private set; } = []; - public List IoWarnings { get; private set; } = []; + public List IoExceptions { get; } = []; + public List IoWarnings { get; } = []; public MdlTab(ModEditWindow edit, byte[] bytes, string path) { @@ -92,10 +92,7 @@ public partial class ModEditWindow .ToList(); }); - task.ContinueWith(t => - { - GamePaths = FinalizeIo(task); - }); + task.ContinueWith(t => { GamePaths = FinalizeIo(task); }); } private EstManipulation[] GetCurrentEstManipulations() @@ -246,8 +243,8 @@ public partial class ModEditWindow private void BeginIo() { PendingIo = true; - IoWarnings = []; - IoExceptions = []; + IoWarnings.Clear(); + IoExceptions.Clear(); } private void FinalizeIo(Task task) @@ -264,8 +261,9 @@ public partial class ModEditWindow { result = getResult(task.Result); if (getNotifier != null) - IoWarnings = getNotifier(task.Result).GetWarnings().ToList(); + IoWarnings.AddRange(getNotifier(task.Result).GetWarnings()); } + PendingIo = false; return result; @@ -273,12 +271,16 @@ public partial class ModEditWindow private void RecordIoExceptions(Exception? exception) { - IoExceptions = exception switch + switch (exception) { - null => [], - AggregateException ae => [.. ae.Flatten().InnerExceptions], - _ => [exception], - }; + case null: break; + case AggregateException ae: + IoExceptions.AddRange(ae.Flatten().InnerExceptions); + break; + default: + IoExceptions.Add(exception); + break; + } } /// Read a file from the active collection or game.