fix panic when adding menuroles on linux (#4558)

* fix panic when adding menuroles on linux

* update changelog

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
Jae-Sung Lee 2025-10-03 08:50:40 +09:00 committed by GitHub
commit 4df077f9b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View file

@ -34,8 +34,11 @@ void addAccelerator(GtkWidget* menuItem, GtkAccelGroup* group, guint key, GdkMod
}
*/
import "C"
import "github.com/wailsapp/wails/v2/pkg/menu"
import "unsafe"
import (
"unsafe"
"github.com/wailsapp/wails/v2/pkg/menu"
)
var menuIdCounter int
var menuItemToId map[*menu.MenuItem]int
@ -81,8 +84,10 @@ func (w *Window) SetApplicationMenu(inmenu *menu.Menu) {
func processMenu(window *Window, menu *menu.Menu) {
for _, menuItem := range menu.Items {
submenu := processSubmenu(menuItem, window.accels)
C.gtk_menu_shell_append(C.toGtkMenuShell(unsafe.Pointer(window.menubar)), submenu)
if menuItem.SubMenu != nil {
submenu := processSubmenu(menuItem, window.accels)
C.gtk_menu_shell_append(C.toGtkMenuShell(unsafe.Pointer(window.menubar)), submenu)
}
}
}

View file

@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added url validation for BrowserOpenURL by @APshenkin in [PR](https://github.com/wailsapp/wails/pull/4484)
- Fixed C compilation error in onWayland on Linux due to declaration after label [#4446](https://github.com/wailsapp/wails/pull/4446) by [@jaesung9507](https://github.com/jaesung9507)
- Use computed style when adding 'wails-drop-target-active' [PR](https://github.com/wailsapp/wails/pull/4420) by [@riannucci](https://github.com/riannucci)
- Fixed panic when adding menuroles on Linux [#4558](https://github.com/wailsapp/wails/pull/4558) by [@jaesung9507](https://github.com/jaesung9507)
## v2.10.2 - 2025-07-06