Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Important] Fix unable to open old projects that contains P flag #1136

Merged
merged 6 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions OpenUtau.Core/Ustx/UExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,7 @@ public UExpression Clone() {
value = value,
};
}

public override string ToString() => $"{abbr.ToUpper()}: {value}";
}
}
10 changes: 7 additions & 3 deletions OpenUtau.Core/Ustx/UProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,27 @@ public void MargeExpression(string oldAbbr, string newAbbr) {
parts.Where(p => p is UVoicePart)
.OfType<UVoicePart>()
.ForEach(p => p.notes.ForEach(n => ConvertNoteExp(n, tracks[p.trackNo])));
} else if (voiceParts != null &&voiceParts.Count > 0) {
} else if (voiceParts != null && voiceParts.Count > 0) {
voiceParts.ForEach(p => p.notes.ForEach(n => ConvertNoteExp(n, tracks[p.trackNo])));
}
expressions.Remove(oldAbbr);

void ConvertNoteExp(UNote note, UTrack track) {
if (note.phonemeExpressions.Any(e => e.abbr == oldAbbr)) {
note.phonemeExpressions.ForEach(oldExp => {
var toRemove = new List<UExpression>();
note.phonemeExpressions.Where(e => e.abbr == oldAbbr).ForEach(oldExp => {
if (!note.phonemeExpressions.Any(newExp => newExp.abbr == newAbbr && newExp.index == oldExp.index)) {
// When there is only old exp, convert it to new exp
oldExp.abbr = newAbbr;
if (track.TryGetExpDescriptor(this, newAbbr, out var descriptor)) {
oldExp.descriptor = descriptor;
}
} else {
note.phonemeExpressions.Remove(oldExp);
// When both old and new exp exist, remove the old one
toRemove.Add(oldExp);
}
});
toRemove.ForEach(exp => note.phonemeExpressions.Remove(exp));
}
}
}
Expand Down
Loading