aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/ui.go
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-04-08 16:12:36 +0200
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-04-23 11:04:59 +0200
commit63e185aa230d1134d8be21fbde54458cdec4cef7 (patch)
treeb4c6841c46897c234d4e6e199b7766f87f2b2a95 /ui/ui.go
parentui: initialize TunnelsView model from service.IPCClientTunnels (diff)
downloadwireguard-windows-63e185aa230d1134d8be21fbde54458cdec4cef7.tar.xz
wireguard-windows-63e185aa230d1134d8be21fbde54458cdec4cef7.zip
ui: synchronize calls from other goroutines into walk
Signed-off-by: Alexander Neumann <alexander.neumann@picos-software.com>
Diffstat (limited to 'ui/ui.go')
-rw-r--r--ui/ui.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/ui/ui.go b/ui/ui.go
index 4acd4a76..7b9a8ce0 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -52,6 +52,13 @@ func RunUI() {
defer tray.Dispose()
// Bind to updates
+ setTunnelState := func(tunnel *service.Tunnel, state service.TunnelState, showNotifications bool) {
+ mtw.Synchronize(func() {
+ mtw.SetTunnelState(tunnel, state)
+ tray.SetTunnelStateWithNotification(tunnel, state, showNotifications)
+ })
+ }
+
service.IPCClientRegisterTunnelChange(func(tunnel *service.Tunnel, state service.TunnelState, err error) {
if err == nil {
return
@@ -66,12 +73,8 @@ func RunUI() {
} else {
tray.ShowError("WireGuard Tunnel Error", err.Error())
}
- })
- service.IPCClientRegisterTunnelChange(func(tunnel *service.Tunnel, state service.TunnelState, err error) {
- tray.SetTunnelStateWithNotification(tunnel, state, err == nil)
- })
- service.IPCClientRegisterTunnelChange(func(tunnel *service.Tunnel, state service.TunnelState, err error) {
- mtw.SetTunnelState(tunnel, state)
+
+ setTunnelState(tunnel, state, err == nil)
})
// Fetch current state
@@ -85,8 +88,7 @@ func RunUI() {
if err != nil {
continue
}
- tray.SetTunnelStateWithNotification(&tunnel, state, false)
- mtw.SetTunnelState(&tunnel, state)
+ setTunnelState(&tunnel, state, false)
}
}()