Fix main window null when checking exitting

This commit is contained in:
Jack251970 2025-05-22 10:47:07 +08:00
parent ac614696b1
commit 8aae92e61d
4 changed files with 4 additions and 4 deletions

View file

@ -32,7 +32,7 @@ namespace Flow.Launcher
#region Public Properties
public static IPublicAPI API { get; private set; }
public static bool Exiting => _mainWindow.CanClose;
public static bool LoadingOrExiting => _mainWindow == null || _mainWindow.CanClose;
#endregion

View file

@ -82,7 +82,7 @@ public partial class SettingWindow
_viewModel.PropertyChanged -= ViewModel_PropertyChanged;
// If app is exiting, settings save is not needed because main window closing event will handle this
if (App.Exiting) return;
if (App.LoadingOrExiting) return;
// Save settings when window is closed
_settings.Save();
App.API.SavePluginSettings();

View file

@ -1729,7 +1729,7 @@ namespace Flow.Launcher.ViewModel
public void Show()
{
// When application is exiting, we should not show the main window
if (App.Exiting) return;
if (App.LoadingOrExiting) return;
// When application is exiting, the Application.Current will be null
Application.Current?.Dispatcher.Invoke(() =>

View file

@ -96,7 +96,7 @@ namespace Flow.Launcher
private void Window_Closed(object sender, EventArgs e)
{
// If app is exiting, settings save is not needed because main window closing event will handle this
if (App.Exiting) return;
if (App.LoadingOrExiting) return;
// Save settings when window is closed
_settings.Save();
}