diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-06 17:31:09 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-07 07:30:36 +0200 |
commit | f7bb880117564901ff98fc292e0ec3c55f75de54 (patch) | |
tree | 00186806fa4b543502d59318859073b12c0a9d63 | |
parent | ui: scale icons according to DPI (diff) | |
download | wireguard-windows-f7bb880117564901ff98fc292e0ec3c55f75de54.tar.xz wireguard-windows-f7bb880117564901ff98fc292e0ec3c55f75de54.zip |
ui: confview should be more picky about which tunnel
-rw-r--r-- | ui/confview.go | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/ui/confview.go b/ui/confview.go index 8f7b82c5..ad5e89b9 100644 --- a/ui/confview.go +++ b/ui/confview.go @@ -414,16 +414,17 @@ func NewConfView(parent walk.Container) (*ConfView, error) { go func() { for range cv.updateTicker.C { if cv.tunnel != nil { + tunnel := cv.tunnel var state service.TunnelState var config conf.Config - if state, _ = cv.tunnel.State(); state == service.TunnelStarted { - config, _ = cv.tunnel.RuntimeConfig() + if state, _ = tunnel.State(); state == service.TunnelStarted { + config, _ = tunnel.RuntimeConfig() } if config.Name == "" { - config, _ = cv.tunnel.StoredConfig() + config, _ = tunnel.StoredConfig() } cv.Synchronize(func() { - cv.setTunnel(cv.tunnel, &config, state) + cv.setTunnel(tunnel, &config, state) }) } } @@ -469,16 +470,18 @@ func (cv *ConfView) onTunnelChanged(tunnel *service.Tunnel, state service.Tunnel cv.interfaze.toggleActive.update(state) } }) - var config conf.Config - if state == service.TunnelStarted { - config, _ = tunnel.RuntimeConfig() - } - if config.Name == "" { - config, _ = tunnel.StoredConfig() + if cv.tunnel != nil && cv.tunnel.Name == tunnel.Name { + var config conf.Config + if state == service.TunnelStarted { + config, _ = tunnel.RuntimeConfig() + } + if config.Name == "" { + config, _ = tunnel.StoredConfig() + } + cv.Synchronize(func() { + cv.setTunnel(tunnel, &config, state) + }) } - cv.Synchronize(func() { - cv.setTunnel(tunnel, &config, state) - }) } func (cv *ConfView) SetTunnel(tunnel *service.Tunnel) { @@ -508,6 +511,10 @@ func (cv *ConfView) SetTunnel(tunnel *service.Tunnel) { } func (cv *ConfView) setTunnel(tunnel *service.Tunnel, config *conf.Config, state service.TunnelState) { + if !(cv.tunnel == nil || tunnel == nil || tunnel.Name == cv.tunnel.Name) { + return + } + cv.name.SetVisible(tunnel != nil) hasSuspended := false |