Skip to content

Commit

Permalink
Fix app not exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Aug 30, 2023
1 parent 94d1903 commit 53dc321
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public partial class App : Application {
WriteIndented = true
};
internal static Settings GlobalSettings = new();
internal static bool exiting = false;

[DllImport("lib.dll")]
private static extern Settings getSettings();
Expand Down Expand Up @@ -56,7 +57,7 @@ protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventA

// Prevent window close
MainWindow.Closed += (s, e) => {
if (GlobalSettings.minimizeToTray) {
if (GlobalSettings.minimizeToTray && !exiting) {
MainWindow.Hide();
e.Handled = true;
} else {
Expand Down
3 changes: 2 additions & 1 deletion core/Views/Tray.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void ShowHideWindowCommand_ExecuteRequested(object _, ExecuteRequestedEve

public void ExitApplicationCommand_ExecuteRequested(object _, ExecuteRequestedEventArgs args) {
TrayIcon.Dispose();
App.MainWindow?.Close();
App.exiting = true;
Application.Current.Exit();
}
}

0 comments on commit 53dc321

Please sign in to comment.