Skip to content

Commit

Permalink
Parent window of error dialog is now determined only when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiko committed May 11, 2024
1 parent 0356417 commit f18023a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion OpenUtau/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ public void OnNext(UCommand cmd, bool isUndo) {
MessageBox.MessageBoxButtons.Ok);
break;
default:
MessageBox.ShowError(this, notif.e, notif.message);
MessageBox.ShowError(this, notif.e, notif.message, true);
break;
}
} else if (cmd is LoadingNotification loadingNotif && loadingNotif.window == typeof(MainWindow)) {
Expand Down
14 changes: 8 additions & 6 deletions OpenUtau/Views/MessageBox.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ public void SetText(string text) {
});
}

public static Task<MessageBoxResult> ShowError(Window parent, Exception? e, string message = "") {
public static Task<MessageBoxResult> ShowError(Window parent, Exception? e, string message = "", bool fromNotif = false) {
string text = message;
string title = ThemeManager.GetString("errors.caption");
IReadOnlyList<Window> dialogs = ((IClassicDesktopStyleApplicationLifetime)Application.Current!.ApplicationLifetime!).Windows;
foreach (var dialog in dialogs) {
if (dialog.IsActive) {
parent = dialog;
break;
if (fromNotif) {
IReadOnlyList<Window> dialogs = ((IClassicDesktopStyleApplicationLifetime)Application.Current!.ApplicationLifetime!).Windows;
foreach (var dialog in dialogs) {
if (dialog.IsActive) {
parent = dialog;
break;
}
}
}

Expand Down

0 comments on commit f18023a

Please sign in to comment.