aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/ui.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-04-27 16:39:06 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-04-27 16:39:06 +0200
commit793549f644302f08f5c1b28451a98ffd0eecf0d1 (patch)
treec154e97a58a9a98af9a3fe316285ee3fdd0b22a3 /ui/ui.go
parentui: enable double buffering on confview (diff)
downloadwireguard-windows-793549f644302f08f5c1b28451a98ffd0eecf0d1.tar.xz
wireguard-windows-793549f644302f08f5c1b28451a98ffd0eecf0d1.zip
ui: fix UI hide/quit logic
Diffstat (limited to 'ui/ui.go')
-rw-r--r--ui/ui.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/ui/ui.go b/ui/ui.go
index d186a905..6ea0a8f6 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -20,6 +20,8 @@ import "C"
var iconProvider *IconProvider
+var shouldQuitManagerWhenExiting = false
+
func RunUI() {
runtime.LockOSThread()
@@ -37,28 +39,32 @@ func RunUI() {
walk.MsgBox(nil, "Unable to initialize icon provider", fmt.Sprint(err), walk.MsgBoxIconError)
return
}
- defer iconProvider.Dispose()
mtw, err := NewManageTunnelsWindow()
if err != nil {
panic(err)
}
- defer mtw.Dispose()
tray, err := NewTray(mtw)
if err != nil {
panic(err)
}
- defer tray.Dispose()
mtw.Run()
+ tray.Dispose()
+ mtw.Dispose()
+ iconProvider.Dispose()
+
+ if shouldQuitManagerWhenExiting {
+ _, err := service.IPCClientQuit(true)
+ if err != nil {
+ walk.MsgBox(nil, "Error Exiting WireGuard", fmt.Sprintf("Unable to exit service due to: %s. You may want to stop WireGuard from the service manager.", err), walk.MsgBoxIconError)
+ }
+ }
}
func onQuit() {
- _, err := service.IPCClientQuit(true)
- if err != nil {
- walk.MsgBox(nil, "Error Exiting WireGuard", fmt.Sprintf("Unable to exit service due to: %s. You may want to stop WireGuard from the service manager.", err), walk.MsgBoxIconError)
- }
+ shouldQuitManagerWhenExiting = true
walk.App().Exit(0)
}