From f18023abadba965f8ca9ab1e00fe5c0a5f606018 Mon Sep 17 00:00:00 2001 From: Maiko Date: Sat, 11 May 2024 16:27:38 +0900 Subject: [PATCH] Parent window of error dialog is now determined only when necessary --- OpenUtau/Views/MainWindow.axaml.cs | 2 +- OpenUtau/Views/MessageBox.axaml.cs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/OpenUtau/Views/MainWindow.axaml.cs b/OpenUtau/Views/MainWindow.axaml.cs index 0d4461a25..db6c748bd 100644 --- a/OpenUtau/Views/MainWindow.axaml.cs +++ b/OpenUtau/Views/MainWindow.axaml.cs @@ -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)) { diff --git a/OpenUtau/Views/MessageBox.axaml.cs b/OpenUtau/Views/MessageBox.axaml.cs index db0d31c26..54446c151 100644 --- a/OpenUtau/Views/MessageBox.axaml.cs +++ b/OpenUtau/Views/MessageBox.axaml.cs @@ -30,14 +30,16 @@ public void SetText(string text) { }); } - public static Task ShowError(Window parent, Exception? e, string message = "") { + public static Task ShowError(Window parent, Exception? e, string message = "", bool fromNotif = false) { string text = message; string title = ThemeManager.GetString("errors.caption"); - IReadOnlyList dialogs = ((IClassicDesktopStyleApplicationLifetime)Application.Current!.ApplicationLifetime!).Windows; - foreach (var dialog in dialogs) { - if (dialog.IsActive) { - parent = dialog; - break; + if (fromNotif) { + IReadOnlyList dialogs = ((IClassicDesktopStyleApplicationLifetime)Application.Current!.ApplicationLifetime!).Windows; + foreach (var dialog in dialogs) { + if (dialog.IsActive) { + parent = dialog; + break; + } } }