Make all destroy functions multi-call safe.
Also, fix an incorrect name for a dispose vfunc.
Testing Done:
Compile only, and the test from LIBGNT-11.
Reviewed at https://reviews.imfreedom.org/r/141/
--- a/gntbutton.c Sun Sep 27 17:46:39 2020 -0500
+++ b/gntbutton.c Sun Sep 27 21:30:55 2020 -0500
@@ -111,7 +111,7 @@
GntButton *button = GNT_BUTTON(widget);
GntButtonPrivate *priv = gnt_button_get_instance_private(button);
+ g_clear_pointer(&priv->text, g_free); --- a/gntentry.c Sun Sep 27 17:46:39 2020 -0500
+++ b/gntentry.c Sun Sep 27 21:30:55 2020 -0500
@@ -1010,25 +1010,28 @@
GntEntry *entry = GNT_ENTRY(widget);
GntEntryPrivate *priv = gnt_entry_get_instance_private(entry);
+ g_clear_pointer(&priv->start, g_free); - priv->history = g_list_first(priv->history);
- g_list_free_full(priv->history, g_free);
+ g_list_free_full(g_list_first(priv->history), g_free); g_list_free_full(priv->suggests, g_free);
gnt_widget_destroy(gnt_widget_get_parent(priv->ddown));
- g_free(priv->search->needle);
+ g_clear_pointer(&priv->search->needle, g_free); + g_clear_pointer(&priv->search, g_free); - jail_killring(priv->killring);
+ g_clear_pointer(&priv->killring, jail_killring); --- a/gntfilesel.c Sun Sep 27 17:46:39 2020 -0500
+++ b/gntfilesel.c Sun Sep 27 21:30:55 2020 -0500
@@ -82,10 +82,11 @@
GntFileSel *sel = GNT_FILE_SEL(widget);
GntFileSelPrivate *priv = gnt_file_sel_get_instance_private(sel);
+ g_clear_pointer(&priv->current, g_free); + g_clear_pointer(&priv->suggest, g_free); g_list_free_full(priv->tags, g_free);
--- a/gntlabel.c Sun Sep 27 17:46:39 2020 -0500
+++ b/gntlabel.c Sun Sep 27 21:30:55 2020 -0500
@@ -55,7 +55,7 @@
gnt_label_destroy(GntWidget *widget)
GntLabel *label = GNT_LABEL(widget);
+ g_clear_pointer(&label->text, g_free); --- a/gntmenu.c Sun Sep 27 17:46:39 2020 -0500
+++ b/gntmenu.c Sun Sep 27 21:30:55 2020 -0500
@@ -414,6 +414,7 @@
GntMenu *menu = GNT_MENU(widget);
g_list_free_full(menu->list, g_object_unref);
--- a/gntmenuitem.c Sun Sep 27 17:46:39 2020 -0500
+++ b/gntmenuitem.c Sun Sep 27 21:30:55 2020 -0500
@@ -59,17 +59,14 @@
*****************************************************************************/
-gnt_menuitem_destroy(GObject *obj)
+gnt_menuitem_dispose(GObject *obj) GntMenuItem *item = GNT_MENU_ITEM(obj);
GntMenuItemPrivate *priv = gnt_menuitem_get_instance_private(item);
- gnt_widget_destroy(GNT_WIDGET(priv->submenu));
+ g_clear_pointer(&priv->text, g_free); + g_clear_pointer((GntWidget **)&priv->submenu, gnt_widget_destroy); + g_clear_pointer(&priv->id, g_free); G_OBJECT_CLASS(gnt_menuitem_parent_class)->dispose(obj);
@@ -79,7 +76,7 @@
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- obj_class->dispose = gnt_menuitem_destroy;
+ obj_class->dispose = gnt_menuitem_dispose; --- a/gnttextview.c Sun Sep 27 17:46:39 2020 -0500
+++ b/gnttextview.c Sun Sep 27 21:30:55 2020 -0500
@@ -245,10 +245,16 @@
gnt_text_view_destroy(GntWidget *widget)
GntTextView *view = GNT_TEXT_VIEW(widget);
- view->list = g_list_first(view->list);
- g_list_free_full(view->list, (GDestroyNotify)free_text_line);
+ g_list_free_full(g_list_first(view->list), + (GDestroyNotify)free_text_line); g_list_free_full(view->tags, (GDestroyNotify)free_tag);
g_string_free(view->string, TRUE);
--- a/gntwindow.c Sun Sep 27 17:46:39 2020 -0500
+++ b/gntwindow.c Sun Sep 27 21:30:55 2020 -0500
@@ -74,8 +74,7 @@
GntWindow *window = GNT_WINDOW(widget);
GntWindowPrivate *priv = gnt_window_get_instance_private(window);
- gnt_widget_destroy(GNT_WIDGET(priv->menu));
+ g_clear_pointer((GntWidget **)&priv->menu, gnt_widget_destroy); g_clear_pointer(&priv->accels, g_hash_table_destroy);
--- a/gntws.c Sun Sep 27 17:46:39 2020 -0500
+++ b/gntws.c Sun Sep 27 21:30:55 2020 -0500
@@ -72,7 +72,7 @@
GntWSPrivate *priv = gnt_ws_get_instance_private(ws);
+ g_clear_pointer(&priv->name, g_free);