From f7bb880117564901ff98fc292e0ec3c55f75de54 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 6 May 2019 17:31:09 +0200 Subject: ui: confview should be more picky about which tunnel --- ui/confview.go | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'ui') 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 -- cgit v1.2.3-59-g8ed1b