From c545c598512f57de2d178f78095f8bc7b31f07c3 Mon Sep 17 00:00:00 2001 From: Ac_K Date: Sat, 3 Jun 2023 05:37:00 +0200 Subject: [PATCH] ava: Fix exit dialog while guest is running. (#5207) * ava: Fix exit dialog while guest is running. There is currently an issue while a game runs, the content dialog creation method check if `IsGameRunning` is true to show the popup. But the condition here is wrong (`window` is null) so it throw a NullException silently in `Dispatcher.UIThread`. This is now fixed by using the right casting. * improve condition * Fix spacing --- src/Ryujinx.Ava/UI/Helpers/ContentDialogHelper.cs | 2 +- src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Ryujinx.Ava/UI/Helpers/ContentDialogHelper.cs b/src/Ryujinx.Ava/UI/Helpers/ContentDialogHelper.cs index d85895fc8..045d508c6 100644 --- a/src/Ryujinx.Ava/UI/Helpers/ContentDialogHelper.cs +++ b/src/Ryujinx.Ava/UI/Helpers/ContentDialogHelper.cs @@ -318,7 +318,7 @@ namespace Ryujinx.Ava.UI.Helpers Window parent = GetMainWindow(); - if (parent is { IsActive: true } and MainWindow window && window.ViewModel.IsGameRunning) + if (parent != null && parent.IsActive && (parent as MainWindow).ViewModel.IsGameRunning) { contentDialogOverlayWindow = new() { diff --git a/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs b/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs index cf84807e3..66988c4b3 100644 --- a/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs +++ b/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs @@ -519,14 +519,14 @@ namespace Ryujinx.Ava.UI.Windows private void ConfirmExit() { Dispatcher.UIThread.InvokeAsync(async () => - { - ViewModel.IsClosing = await ContentDialogHelper.CreateExitDialog(); + { + ViewModel.IsClosing = await ContentDialogHelper.CreateExitDialog(); - if (ViewModel.IsClosing) - { - Close(); - } - }); + if (ViewModel.IsClosing) + { + Close(); + } + }); } public async void LoadApplications()