Author: cazfi Date: Fri Sep 11 17:43:35 2015 New Revision: 29859 URL: http://svn.gna.org/viewcvs/freeciv?rev=29859&view=rev Log: Free gtk-clients' unit pixmap table on exit.
See bug #23862 Modified: branches/S2_6/client/gui-gtk-2.0/gui_main.c branches/S2_6/client/gui-gtk-3.0/gui_main.c Modified: branches/S2_6/client/gui-gtk-2.0/gui_main.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/gui_main.c?rev=29859&r1=29858&r2=29859&view=diff ============================================================================== --- branches/S2_6/client/gui-gtk-2.0/gui_main.c (original) +++ branches/S2_6/client/gui-gtk-2.0/gui_main.c Fri Sep 11 17:43:35 2015 @@ -223,6 +223,8 @@ static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data); +static void free_unit_table(void); + /**************************************************************************** Called by the tileset code to set the font size that should be used to draw the city names and productions. @@ -907,22 +909,18 @@ } /************************************************************************** - Called when the tileset is changed to reset the unit pixmap table. -**************************************************************************/ -void reset_unit_table(void) -{ - int i; - + Free unit pixmap table. +**************************************************************************/ +static void free_unit_table(void) +{ if (unit_pixmap_button) { - /* Unreference all of the widgets that we're about to reallocate, thus - * avoiding a memory leak. Remove them from the container first, just - * to be safe. Note, the widgets are ref'd in - * populatate_unit_pixmap_table. */ gtk_container_remove(GTK_CONTAINER(unit_pixmap_table), unit_pixmap_button); g_object_unref(unit_pixmap); g_object_unref(unit_pixmap_button); if (!options.gui_gtk2_small_display_layout) { + int i; + for (i = 0; i < num_units_below; i++) { gtk_container_remove(GTK_CONTAINER(unit_pixmap_table), unit_below_pixmap_button[i]); @@ -936,6 +934,18 @@ g_object_unref(more_arrow_pixmap_button); g_object_unref(more_arrow_pixmap_container); } +} + +/************************************************************************** + Called when the tileset is changed to reset the unit pixmap table. +**************************************************************************/ +void reset_unit_table(void) +{ + /* Unreference all of the widgets that we're about to reallocate, thus + * avoiding a memory leak. Remove them from the container first, just + * to be safe. Note, the widgets are ref'd in + * populatate_unit_pixmap_table. */ + free_unit_table(); populate_unit_pixmap_table(); @@ -1693,6 +1703,7 @@ happiness_dialog_done(); diplomacy_dialog_done(); cma_fe_done(); + free_unit_table(); gtk_widget_destroy(toplevel_tabs); tileset_free_tiles(tileset); } Modified: branches/S2_6/client/gui-gtk-3.0/gui_main.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/gui_main.c?rev=29859&r1=29858&r2=29859&view=diff ============================================================================== --- branches/S2_6/client/gui-gtk-3.0/gui_main.c (original) +++ branches/S2_6/client/gui-gtk-3.0/gui_main.c Fri Sep 11 17:43:35 2015 @@ -208,6 +208,8 @@ static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data); +static void free_unit_table(void); + /**************************************************************************** Called by the tileset code to set the font size that should be used to draw the city names and productions. @@ -911,22 +913,18 @@ } /************************************************************************** - Called when the tileset is changed to reset the unit pixmap table. -**************************************************************************/ -void reset_unit_table(void) -{ - int i; - + Free unit pixmap table. +**************************************************************************/ +static void free_unit_table(void) +{ if (unit_pixmap_button) { - /* Unreference all of the widgets that we're about to reallocate, thus - * avoiding a memory leak. Remove them from the container first, just - * to be safe. Note, the widgets are ref'd in - * populatate_unit_pixmap_table. */ gtk_container_remove(GTK_CONTAINER(unit_pixmap_table), unit_pixmap_button); g_object_unref(unit_pixmap); g_object_unref(unit_pixmap_button); if (!options.gui_gtk3_small_display_layout) { + int i; + for (i = 0; i < num_units_below; i++) { gtk_container_remove(GTK_CONTAINER(unit_pixmap_table), unit_below_pixmap_button[i]); @@ -940,6 +938,18 @@ g_object_unref(more_arrow_pixmap_button); g_object_unref(more_arrow_pixmap_container); } +} + +/************************************************************************** + Called when the tileset is changed to reset the unit pixmap table. +**************************************************************************/ +void reset_unit_table(void) +{ + /* Unreference all of the widgets that we're about to reallocate, thus + * avoiding a memory leak. Remove them from the container first, just + * to be safe. Note, the widgets are ref'd in + * populatate_unit_pixmap_table. */ + free_unit_table(); populate_unit_pixmap_table(); @@ -1729,6 +1739,7 @@ happiness_dialog_done(); diplomacy_dialog_done(); cma_fe_done(); + free_unit_table(); gtk_widget_destroy(toplevel_tabs); tileset_free_tiles(tileset); } _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits