Skip to content

Commit

Permalink
Merge pull request #5405 from andydotxyz/fix/5401
Browse files Browse the repository at this point in the history
Fix mobile shutdown
  • Loading branch information
andydotxyz authored Jan 13, 2025
2 parents 36de697 + d6d65dc commit f92cda8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
12 changes: 11 additions & 1 deletion internal/driver/mobile/app/darwin_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,18 @@ func eventMouseDragged(x, y float32) { sendTouch(touch.TypeMove, x, y) }
//export eventMouseEnd
func eventMouseEnd(x, y float32) { sendTouch(touch.TypeEnd, x, y) }

var stopped = false

//export lifecycleDead
func lifecycleDead() { theApp.sendLifecycle(lifecycle.StageDead) }
func lifecycleDead() {
if stopped {
return
}
stopped = true

theApp.sendLifecycle(lifecycle.StageDead)
theApp.events.Close()
}

//export eventKey
func eventKey(runeVal int32, direction uint8, code uint16, flags uint32) {
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/mobile/app/darwin_desktop.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ - (void)applicationWillUnhide:(NSNotification *)notification {
}

- (void)windowWillClose:(NSNotification *)notification {
lifecycleAlive();
lifecycleDead();
}

- (BOOL)acceptsFirstResponder {
Expand Down
11 changes: 10 additions & 1 deletion internal/driver/mobile/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,16 @@ func (d *driver) Run() {
draw := time.NewTicker(time.Second / 60)
defer func() {
l := fyne.CurrentApp().Lifecycle().(*intapp.Lifecycle)
l.WaitForEvents()

// exhaust the event queue
go func() {
l.WaitForEvents()
d.queuedFuncs.Close()
}()
for fn := range d.queuedFuncs.Out() {
fn()
}

l.DestroyEventQueue()
}()

Expand Down

0 comments on commit f92cda8

Please sign in to comment.