aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/tunnelspage.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-04-29 15:52:17 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-04-29 15:52:17 +0200
commit3245ef2f821fee0580f7d97c6f05223c2673e318 (patch)
treea37424f17b611c6d5d04da9fceb4a756dadf52ab /ui/tunnelspage.go
parentui: account for IPC failures in UI initialization (diff)
downloadwireguard-windows-3245ef2f821fee0580f7d97c6f05223c2673e318.tar.xz
wireguard-windows-3245ef2f821fee0580f7d97c6f05223c2673e318.zip
service: pass global state with notification
Diffstat (limited to 'ui/tunnelspage.go')
-rw-r--r--ui/tunnelspage.go28
1 files changed, 18 insertions, 10 deletions
diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go
index 469ecdeb..5df74d05 100644
--- a/ui/tunnelspage.go
+++ b/ui/tunnelspage.go
@@ -265,17 +265,25 @@ func (tp *TunnelsPage) deleteTunnel(tunnel *service.Tunnel) {
// Handlers
func (tp *TunnelsPage) onTunnelsViewItemActivated() {
- oldState, err := tp.tunnelsView.CurrentTunnel().Toggle()
- if err != nil {
- if oldState == service.TunnelUnknown {
- walk.MsgBox(tp.Form(), "Failed to determine tunnel state", err.Error(), walk.MsgBoxIconError)
- } else if oldState == service.TunnelStopped {
- walk.MsgBox(tp.Form(), "Failed to activate tunnel", err.Error(), walk.MsgBoxIconError)
- } else if oldState == service.TunnelStarted {
- walk.MsgBox(tp.Form(), "Failed to deactivate tunnel", err.Error(), walk.MsgBoxIconError)
+ go func() {
+ globalState, err := service.IPCClientGlobalState()
+ if err != nil || (globalState != service.TunnelStarted && globalState != service.TunnelStopped) {
+ return
}
- return
- }
+ oldState, err := tp.tunnelsView.CurrentTunnel().Toggle()
+ if err != nil {
+ tp.Synchronize(func() {
+ if oldState == service.TunnelUnknown {
+ walk.MsgBox(tp.Form(), "Failed to determine tunnel state", err.Error(), walk.MsgBoxIconError)
+ } else if oldState == service.TunnelStopped {
+ walk.MsgBox(tp.Form(), "Failed to activate tunnel", err.Error(), walk.MsgBoxIconError)
+ } else if oldState == service.TunnelStarted {
+ walk.MsgBox(tp.Form(), "Failed to deactivate tunnel", err.Error(), walk.MsgBoxIconError)
+ }
+ })
+ return
+ }
+ }()
}
func (tp *TunnelsPage) onEditTunnel() {