Skip to content

Commit

Permalink
Fix unable to save
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiko committed Jun 9, 2024
1 parent 6577590 commit 3a57ab9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
29 changes: 19 additions & 10 deletions OpenUtau.Core/Format/USTx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,28 @@ public static UProject Create() {
}

public static void Save(string filePath, UProject project) {
project.ustxVersion = kUstxVersion;
project.FilePath = filePath;
project.BeforeSave();
File.WriteAllText(filePath, Yaml.DefaultSerializer.Serialize(project), Encoding.UTF8);
project.Saved = true;
project.AfterSave();
try {
project.ustxVersion = kUstxVersion;
project.FilePath = filePath;
project.BeforeSave();
File.WriteAllText(filePath, Yaml.DefaultSerializer.Serialize(project), Encoding.UTF8);
project.Saved = true;
project.AfterSave();
} catch (Exception ex) {
var e = new MessageCustomizableException("Failed to save ustx: {filePath}", $"<translate:errors.failed.save>: {filePath}", ex);
DocManager.Inst.ExecuteCmd(new ErrorMessageNotification(e));
}
}

public static void AutoSave(string filePath, UProject project) {
project.ustxVersion = kUstxVersion;
project.BeforeSave();
File.WriteAllText(filePath, Yaml.DefaultSerializer.Serialize(project), Encoding.UTF8);
project.AfterSave();
try {
project.ustxVersion = kUstxVersion;
project.BeforeSave();
File.WriteAllText(filePath, Yaml.DefaultSerializer.Serialize(project), Encoding.UTF8);
project.AfterSave();
} catch (Exception ex) {
Log.Error(ex, $"Failed to autosave: {filePath}");
}
}

public static UProject Load(string filePath) {
Expand Down
6 changes: 5 additions & 1 deletion OpenUtau.Core/Ustx/UTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ public bool ValidateVoiceColor(out string[] oldColors, out string[] newColors) {
public void BeforeSave() {
singer = Singer?.Id;
phonemizer = Phonemizer.GetType().FullName;
VoiceColorNames = VoiceColorExp.options.ToArray();
if (Singer != null && Singer.Found && VoiceColorExp != null && VoiceColorExp.options.Length > 0) {
VoiceColorNames = VoiceColorExp.options.ToArray();
} else {
VoiceColorNames = new string[] { "" };
}
}

public void AfterLoad(UProject project) {
Expand Down

0 comments on commit 3a57ab9

Please sign in to comment.