diff --git a/docs/src/content/docs/changelog.mdx b/docs/src/content/docs/changelog.mdx index 6b9ca3118..5047a6feb 100644 --- a/docs/src/content/docs/changelog.mdx +++ b/docs/src/content/docs/changelog.mdx @@ -89,6 +89,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed hidden menu items on macOS by [@leaanthony](https://github.com/leaanthony) - Fixed handling and formatting of errors in message processors by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066) -  Fixed skipped service shutdown when quitting application by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066) +-  Ensure menu updates occur on the main thread by [@leaanthony](https://github.com/leaanthony) ### Changed diff --git a/v3/pkg/application/menu_darwin.go b/v3/pkg/application/menu_darwin.go index 3a5fa69e4..1e3fc7197 100644 --- a/v3/pkg/application/menu_darwin.go +++ b/v3/pkg/application/menu_darwin.go @@ -72,12 +72,14 @@ func newMenuImpl(menu *Menu) *macosMenu { } func (m *macosMenu) update() { - if m.nsMenu == nil { - m.nsMenu = C.createNSMenu(C.CString(m.menu.label)) - } else { - C.clearMenu(m.nsMenu) - } - m.processMenu(m.nsMenu, m.menu) + InvokeSync(func() { + if m.nsMenu == nil { + m.nsMenu = C.createNSMenu(C.CString(m.menu.label)) + } else { + C.clearMenu(m.nsMenu) + } + m.processMenu(m.nsMenu, m.menu) + }) } func (m *macosMenu) processMenu(parent unsafe.Pointer, menu *Menu) {