GNOME Bugzilla – Bug 376443
gtk_image_menu_item_new_with_label / gtk_image_menu_item_new_with_mnemonic have incorrect initial ref_count
Last modified: 2007-04-16 12:04:04 UTC
When a menu item is created with gtk_image_menu_item_new_with_label() or gtk_image_menu_item_new_with_mnemonic(), it will start life with a ref_count of 2. This means that it will not be destroyed when removed from the container it is added to using gtk_container_remove(). (I realize that you can use gtk_widget_destroy() instead of gtk_container_remove() and it will make sure that the the menu item is removed and destroyed.) The problem appears to be that gtk_accel_label_set_accel_widget() is called in the gtk_image_menu_item_new...() methods, which adds an additional ref_count. Perhaps the menu item should simply be unreffed after the gtk_accel_label_set_accel_widget() call?
I'd say this applies to gtk_menu_item_new_with_{label,mnmemonic} too.
See bug 344858
indeed, this is a dupe. *** This bug has been marked as a duplicate of 344858 ***