From: John Darrington Date: Sat, 27 Jun 2020 05:27:25 +0000 (+0200) Subject: PSPPIRE: Fix memory leaks when creating windows X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38a69a5fad0b824bbcb7662f8fa1aa23f04b3349;p=pspp PSPPIRE: Fix memory leaks when creating windows --- diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index 7d478a642b..8dcde94ad5 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -326,6 +326,7 @@ insert_menuitem_into_menu (PsppireWindow *window, gpointer key) GtkWidget *item; filename = g_filename_display_name (key); item = gtk_check_menu_item_new_with_label (filename); + g_object_ref_sink (item); g_free (filename); g_hash_table_insert (window->menuitem_table, key, item); @@ -411,17 +412,19 @@ psppire_window_init (PsppireWindow *window) window->list_name = NULL; window->edited = NULL; - window->menuitem_table = g_hash_table_new (g_str_hash, g_str_equal); + window->menuitem_table = g_hash_table_new_full (g_str_hash, g_str_equal, + NULL, g_object_unref); g_signal_connect (window, "realize", G_CALLBACK (insert_existing_items), NULL); - window->insert_handler = g_signal_connect (psppire_window_register_new (), + PsppireWindowRegister *reg = psppire_window_register_new (); + window->insert_handler = g_signal_connect (reg, "inserted", G_CALLBACK (insert_menuitem), window); - window->remove_handler = g_signal_connect (psppire_window_register_new (), + window->remove_handler = g_signal_connect (reg, "removed", G_CALLBACK (remove_menuitem), window);