Skip to content

Commit 4df077f

Browse files
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>
1 parent db22cb2 commit 4df077f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

v2/internal/frontend/desktop/linux/menu.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ void addAccelerator(GtkWidget* menuItem, GtkAccelGroup* group, guint key, GdkMod
3434
}
3535
*/
3636
import "C"
37-
import "github.com/wailsapp/wails/v2/pkg/menu"
38-
import "unsafe"
37+
import (
38+
"unsafe"
39+
40+
"github.com/wailsapp/wails/v2/pkg/menu"
41+
)
3942

4043
var menuIdCounter int
4144
var menuItemToId map[*menu.MenuItem]int
@@ -81,8 +84,10 @@ func (w *Window) SetApplicationMenu(inmenu *menu.Menu) {
8184

8285
func processMenu(window *Window, menu *menu.Menu) {
8386
for _, menuItem := range menu.Items {
84-
submenu := processSubmenu(menuItem, window.accels)
85-
C.gtk_menu_shell_append(C.toGtkMenuShell(unsafe.Pointer(window.menubar)), submenu)
87+
if menuItem.SubMenu != nil {
88+
submenu := processSubmenu(menuItem, window.accels)
89+
C.gtk_menu_shell_append(C.toGtkMenuShell(unsafe.Pointer(window.menubar)), submenu)
90+
}
8691
}
8792
}
8893

website/src/pages/changelog.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Added url validation for BrowserOpenURL by @APshenkin in [PR](https://github.com/wailsapp/wails/pull/4484)
2727
- 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)
2828
- Use computed style when adding 'wails-drop-target-active' [PR](https://github.com/wailsapp/wails/pull/4420) by [@riannucci](https://github.com/riannucci)
29+
- Fixed panic when adding menuroles on Linux [#4558](https://github.com/wailsapp/wails/pull/4558) by [@jaesung9507](https://github.com/jaesung9507)
2930

3031
## v2.10.2 - 2025-07-06
3132

0 commit comments

Comments
 (0)