diff options
author | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-04-08 16:12:36 +0200 |
---|---|---|
committer | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-04-23 11:04:59 +0200 |
commit | 63e185aa230d1134d8be21fbde54458cdec4cef7 (patch) | |
tree | b4c6841c46897c234d4e6e199b7766f87f2b2a95 /ui/ui.go | |
parent | ui: initialize TunnelsView model from service.IPCClientTunnels (diff) | |
download | wireguard-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 '')
-rw-r--r-- | ui/ui.go | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -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) } }() |