Skip to content

Commit

Permalink
[v3] Improve OnShutdown (#3190)
Browse files Browse the repository at this point in the history
* [v3] Improve OnShutdown

* add change log
  • Loading branch information
almas1992 authored Jan 10, 2024
1 parent f759162 commit 3cd26a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions mkdocs-website/docs/en/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions v3/pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions v3/pkg/application/options_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3cd26a2

Please sign in to comment.