GNOME Bugzilla – Bug 161668
GtkItemFactory stop working with 2.6.0
Last modified: 2011-02-04 16:17:22 UTC
code : GtkItemFactoryEntry menu_items[] = { {"/GNU Gadu", NULL, NULL, 0, "<Branch>", NULL}, {_("/GNU Gadu/Preferences"), NULL, gui_preferences, 0, "<StockItem>", GTK_STOCK_PREFERENCES}, {_("/GNU Gadu/"), NULL, NULL, 0, "<Separator>", NULL}, {_("/GNU Gadu/About"), "<CTRL>a", gui_about, 0, "<StockItem>", GTK_STOCK_DIALOG_INFO}, {_("/GNU Gadu/Quit"), "<CTRL>q", gui_quit, 0, "<StockItem>", GTK_STOCK_QUIT}, {"/Menu", NULL, NULL, 0, "<Branch>", NULL}, }; gint Nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); accel_group = gtk_accel_group_new(); item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); segfault like this :
+ Trace 53678
Unique stack trace, according to simple-dup-finder.
I missed one line... the code is: GtkItemFactoryEntry menu_items[] = { {"/GNU Gadu", NULL, NULL, 0, "<Branch>", NULL}, {_("/GNU Gadu/Preferences"), NULL, gui_preferences, 0, "<StockItem>", GTK_STOCK_PREFERENCES}, {_("/GNU Gadu/"), NULL, NULL, 0, "<Separator>", NULL}, {_("/GNU Gadu/About"), "<CTRL>a", gui_about, 0, "<StockItem>", GTK_STOCK_DIALOG_INFO}, {_("/GNU Gadu/Quit"), "<CTRL>q", gui_quit, 0, "<StockItem>", GTK_STOCK_QUIT}, {"/Menu", NULL, NULL, 0, "<Branch>", NULL}, }; gint Nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); accel_group = gtk_accel_group_new(); item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); gtk_item_factory_create_items(item_factory, Nmenu_items, menu_items, NULL);
full test case : #include <stdlib.h> #include <gtk/gtk.h> #include <string.h> int main() { GtkAccelGroup *accel_group = NULL; GtkItemFactory *item_factory; gtk_init(NULL,NULL); GtkItemFactoryEntry menu_items[] = { {"/GNU Gadu", NULL, NULL, 0, "<Branch>", NULL}, {"/GNU Gadu/Preferences", NULL, NULL, 0, "<StockItem>", GTK_STOCK_PREFERENCES}, {"/GNU Gadu/", NULL, NULL, 0, "<Separator>", NULL}, {"/GNU Gadu/About", "<CTRL>a", NULL, 0, "<StockItem>", GTK_STOCK_DIALOG_INFO}, {"/GNU Gadu/Quit", "<CTRL>q", NULL, 0, "<StockItem>", GTK_STOCK_QUIT}, {"/Menu", NULL, NULL, 0, "<Branch>", NULL}, }; gint Nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); accel_group = gtk_accel_group_new(); item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); gtk_item_factory_create_items(item_factory, Nmenu_items, menu_items, NULL); }
This turned out to be a glib problem: 2004-12-19 Matthias Clasen <mclasen@redhat.com> * glib/goption.c (g_option_context_parse): Call post-parse hooks also if argv is NULL. (#161668, Marcin Krzyzanowski)
*** Bug 162930 has been marked as a duplicate of this bug. ***