Popup GtkMenu (always?) leaks
Steps to reproduce
- Run the snippet provided below
- Notice that
gtk_menu_new()
is called butgtk_menu_finalize()
is not.
gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "delete_event", gtk_main_quit, NULL);
gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);
// Popup menus are leaked even when destroyed properly
GtkWidget* menu = gtk_menu_new();
gtk_widget_destroy(menu);
gtk_widget_show_all(window);
gtk_main();
Current behavior
GtkMenu
object is leaked.
Expected outcome
GtkMenu
should be freed.
Version information
GTK 3.24.28
Additional information
I have traced g_object_ref()
and g_object_unref()
and found that the problem is due to the following code in gtk_menu_destroy()
:
/* Add back the reference count for being a child */
if (priv->needs_destruction_ref)
{
priv->needs_destruction_ref = FALSE;
g_object_ref (widget);
}
I understand that this is because popup menus are not children.