From fae2b311de9c3318e9ba2cebf933a11eb975cf6e Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 4 Jul 2026 12:46:30 +0200 Subject: [PATCH] fix(tray): set an accel group on the dbusmenu client to stop Gtk-CRITICAL crash When a tray item exports menu accelerators (e.g. Mattermost), libdbusmenu-gtk calls gtk_widget_set_accel_path() with a NULL accel group because the DbusmenuGtkClient never had one assigned. This raises a Gtk-CRITICAL that corrupts menu state, and aborts Waybar when running under G_DEBUG=fatal-criticals. Assign a fresh GtkAccelGroup to the client right after the menu is created, before it is populated or shown. Fixes #5142. --- src/modules/sni/item.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/modules/sni/item.cpp b/src/modules/sni/item.cpp index 1c28d7af..843f386b 100644 --- a/src/modules/sni/item.cpp +++ b/src/modules/sni/item.cpp @@ -577,6 +577,15 @@ void Item::makeMenu() { if (dbus_menu != nullptr) { g_object_ref_sink(G_OBJECT(dbus_menu)); g_object_weak_ref(G_OBJECT(dbus_menu), (GWeakNotify)onMenuDestroyed, this); + // Provide an accel group to the dbusmenu client. Without one, items that export menu + // accelerators (e.g. Mattermost) trigger gtk_widget_set_accel_path() with a NULL accel group, + // which raises a Gtk-CRITICAL and corrupts menu state (or aborts under fatal-criticals). + DbusmenuGtkClient* client = dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(dbus_menu)); + if (client != nullptr) { + GtkAccelGroup* accel_group = gtk_accel_group_new(); + dbusmenu_gtkclient_set_accel_group(client, accel_group); + g_object_unref(accel_group); + } gtk_menu = Glib::wrap(GTK_MENU(dbus_menu)); gtk_menu->attach_to_widget(event_box); }