Skip to content

Commit

Permalink
dont try to log the shutdown while shutting down, which causes a dead…
Browse files Browse the repository at this point in the history
…lock
  • Loading branch information
olebeck committed Jul 11, 2024
1 parent 3c586cb commit 51256da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ui/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gui
import (
"context"
"errors"
"fmt"
"image/color"

"gioui.org/app"
Expand Down Expand Up @@ -112,6 +113,7 @@ func (g *GUI) loop(window *app.Window) error {

for {
e := window.Event()
fmt.Printf("window.Event %+#v\n", e)

if g.ctx.Err() != nil && !closing {
logrus.Info("Closing")
Expand All @@ -121,6 +123,7 @@ func (g *GUI) loop(window *app.Window) error {
}
switch e := e.(type) {
case app.DestroyEvent:
g.router.ShuttingDown = true
logrus.Info("Closing")
g.cancel(errors.New("Closing"))
g.router.Wg.Wait()
Expand Down
4 changes: 3 additions & 1 deletion ui/gui/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func (l *logger) Fire(e *logrus.Entry) error {
l.l.Lock()
l.lines = append(l.lines, e)
l.l.Unlock()
l.router.Invalidate()
if !l.router.ShuttingDown {
l.router.Invalidate()
}
return nil
}
2 changes: 2 additions & 0 deletions ui/gui/pages/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type Router struct {
showLogs bool

popups []popups.Popup

ShuttingDown bool
}

func NewRouter(uii ui.UI) *Router {
Expand Down

0 comments on commit 51256da

Please sign in to comment.