Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mobile shutdown #5405

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading