Description
v3/pkg/application/menu_linux.go (default GTK4 build) and menu_linux_gtk3.go (legacy GTK3 build) both contain a linuxMenu.processed bool field that is set to true on first call to processMenu() and used as a one-way guard:
impl := menu.impl.(*linuxMenu)
if impl.processed {
// Menu already processed, skip re-processing to avoid duplicates
return
}
impl.processed = true
As a result, subsequent calls to Menu.Update() (which calls m.update() → m.processMenu(m.menu)) become silent no-ops after the first call. Adding/removing menu items, rebuilding after Clear(), or any other runtime mutation will not be reflected in the native menu.
Reproduction
menu := app.NewMenu()
menu.Add("Item A")
window.SetMenu(menu)
// Later, at runtime:
menu.Add("Item B")
menu.Update() // expected: native menu now shows Item A + Item B. actual: still just Item A.
Scope
Suggested fix
Instead of a one-way processed guard, either:
- Clear/destroy the native menu and rebuild from scratch on every
Update() call (simpler, slight flicker).
- Diff the current
menu.items against the native menu's state and apply minimal mutations (more code, no flicker).
Option 1 is probably right unless someone reports flicker; menu updates are rare enough that the simple path is preferable.
References
Description
v3/pkg/application/menu_linux.go(default GTK4 build) andmenu_linux_gtk3.go(legacy GTK3 build) both contain alinuxMenu.processed boolfield that is set totrueon first call toprocessMenu()and used as a one-way guard:As a result, subsequent calls to
Menu.Update()(which callsm.update()→m.processMenu(m.menu)) become silent no-ops after the first call. Adding/removing menu items, rebuilding afterClear(), or any other runtime mutation will not be reflected in the native menu.Reproduction
Scope
menu_linux.go) and the legacy GTK3 path (menu_linux_gtk3.go).Suggested fix
Instead of a one-way
processedguard, either:Update()call (simpler, slight flicker).menu.itemsagainst the native menu's state and apply minimal mutations (more code, no flicker).Option 1 is probably right unless someone reports flicker; menu updates are rare enough that the simple path is preferable.
References