Skip to content

Commit a5e2e42

Browse files
committed
[darwin] Ensure menu updates occur on main thread
1 parent d5a8f1e commit a5e2e42

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

docs/src/content/docs/changelog.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8989
- Fixed hidden menu items on macOS by [@leaanthony](https://github.com/leaanthony)
9090
- Fixed handling and formatting of errors in message processors by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
9191
-  Fixed skipped service shutdown when quitting application by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
92+
-  Ensure menu updates occur on the main thread by [@leaanthony](https://github.com/leaanthony)
9293

9394
### Changed
9495

v3/pkg/application/menu_darwin.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ func newMenuImpl(menu *Menu) *macosMenu {
7272
}
7373

7474
func (m *macosMenu) update() {
75-
if m.nsMenu == nil {
76-
m.nsMenu = C.createNSMenu(C.CString(m.menu.label))
77-
} else {
78-
C.clearMenu(m.nsMenu)
79-
}
80-
m.processMenu(m.nsMenu, m.menu)
75+
InvokeSync(func() {
76+
if m.nsMenu == nil {
77+
m.nsMenu = C.createNSMenu(C.CString(m.menu.label))
78+
} else {
79+
C.clearMenu(m.nsMenu)
80+
}
81+
m.processMenu(m.nsMenu, m.menu)
82+
})
8183
}
8284

8385
func (m *macosMenu) processMenu(parent unsafe.Pointer, menu *Menu) {

0 commit comments

Comments
 (0)