clean up context
parent
2c7d5a16f6
commit
247cc634be
|
|
@ -50,9 +50,11 @@ func (v *flashView) setMessage(level flashLevel, msg ...string) {
|
||||||
}
|
}
|
||||||
var ctx1, ctx2 context.Context
|
var ctx1, ctx2 context.Context
|
||||||
{
|
{
|
||||||
|
var timerCancel context.CancelFunc
|
||||||
ctx1, v.cancel = context.WithCancel(context.TODO())
|
ctx1, v.cancel = context.WithCancel(context.TODO())
|
||||||
ctx2, _ = context.WithTimeout(context.TODO(), flashDelay*time.Second)
|
ctx2, timerCancel = context.WithTimeout(context.TODO(), flashDelay*time.Second)
|
||||||
go func(ctx1, ctx2 context.Context) {
|
go func(ctx1, ctx2 context.Context, timerCancel context.CancelFunc) {
|
||||||
|
defer timerCancel()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
// Timer canceled bail now
|
// Timer canceled bail now
|
||||||
|
|
@ -67,7 +69,7 @@ func (v *flashView) setMessage(level flashLevel, msg ...string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(ctx1, ctx2)
|
}(ctx1, ctx2, timerCancel)
|
||||||
}
|
}
|
||||||
_, _, width, _ := v.GetRect()
|
_, _, width, _ := v.GetRect()
|
||||||
if width <= 15 {
|
if width <= 15 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue