[v3] Improve OnShutdown (#3190)

* [v3] Improve OnShutdown

* add change log
This commit is contained in:
ALMAS 2024-01-10 20:28:15 +08:00 committed by GitHub
commit 3cd26a2220
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View file

@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [linux] add onKeyPress logic to convert linux keypress into an accelerator @[Atterpac](https://github.com/Atterpac) in[#3022](https://github.com/wailsapp/wails/pull/3022])
- [linux] add task `run:linux` by [@marcus-crane](https://github.com/marcus-crane) in [#3146](https://github.com/wailsapp/wails/pull/3146)
- export `SetIcon` method by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3147)
- Improve `OnShutdown` by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3189)
### Fixed

View file

@ -291,10 +291,6 @@ type App struct {
// Keybindings
keyBindings map[string]func(window *WebviewWindow)
// OnShutdown is called when the application is about to quit.
// This is useful for cleanup tasks.
// The shutdown process blocks until this function returns
OnShutdown func()
performingShutdown bool
}
@ -609,8 +605,8 @@ func (a *App) Quit() {
return
}
a.performingShutdown = true
if a.OnShutdown != nil {
a.OnShutdown()
if a.options.OnShutdown != nil {
a.options.OnShutdown()
}
InvokeSync(func() {
a.windowsLock.RLock()

View file

@ -51,6 +51,11 @@ type Options struct {
// KeyBindings is a map of key bindings to functions
KeyBindings map[string]func(window *WebviewWindow)
// OnShutdown is called when the application is about to quit.
// This is useful for cleanup tasks.
// The shutdown process blocks until this function returns
OnShutdown func()
}
// AssetOptions defines the configuration of the AssetServer.