GNOME Bugzilla – Bug 645483
GtkToolItem's handling of ->priv->menu_item
Last modified: 2018-02-10 04:37:32 UTC
->priv->menu_item is a GtkWidget created by gtk_action_create_menu_item. It should not be assumed to have and keep a ref-count of 1. Therefore, it should be explicitly destroyed by gtk_tool_item_dispose and, perhaps, gtk_tool_item_set_proxy_menu_item. Relatedly, the current contents of gtk_tool_item_finalize seems to be more appropriate for gtk_tool_item_dispose. (But then the items need to be zeroed.)
I should add that Gtk+ is perfectly capable of supplying that second ref all by itself. I.e., whenever an overflow menu item is created, it is leaked. This didn't use to be the case. The extra ref seems to be set deep down in gtk_accel_label_set_accel_widget, unless I'm mistaken.
It's a case of circular links: GtkMenuItem holds a ref to its child, a GtkAccelLabel. The GtkAccelLabel holds a ref to the GtkMenuItem as its "accel widget". Something needs to break those links. The upcoming patch works for me. Note: contain debug code. Offline CC-ing jpetersen@openismus.com who appears to have refactored GtkMenuItem to create the ref loop.
Created attachment 185376 [details] [review] Patch with debug code
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue for it.