From 09d52411baae3852c719beaf5877b62b250cdcfe Mon Sep 17 00:00:00 2001 From: oxygen-dioxide <54425948+oxygen-dioxide@users.noreply.github.com> Date: Sun, 19 May 2024 10:37:33 +0800 Subject: [PATCH] fix expression merge --- OpenUtau.Core/Ustx/UProject.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenUtau.Core/Ustx/UProject.cs b/OpenUtau.Core/Ustx/UProject.cs index 8597b8e19..30338d55a 100644 --- a/OpenUtau.Core/Ustx/UProject.cs +++ b/OpenUtau.Core/Ustx/UProject.cs @@ -97,6 +97,7 @@ public void MargeExpression(string oldAbbr, string newAbbr) { void ConvertNoteExp(UNote note, UTrack track) { if (note.phonemeExpressions.Any(e => e.abbr == oldAbbr)) { + var toRemove = new List(); note.phonemeExpressions.ForEach(oldExp => { if (!note.phonemeExpressions.Any(newExp => newExp.abbr == newAbbr && newExp.index == oldExp.index)) { oldExp.abbr = newAbbr; @@ -104,9 +105,12 @@ void ConvertNoteExp(UNote note, UTrack track) { oldExp.descriptor = descriptor; } } else { - note.phonemeExpressions.Remove(oldExp); + toRemove.Add(oldExp); } }); + foreach(var exp in toRemove){ + note.phonemeExpressions.Remove(exp); + } } } }