Author: cazfi
Date: Fri Sep 11 17:43:43 2015
New Revision: 29860

URL: http://svn.gna.org/viewcvs/freeciv?rev=29860&view=rev
Log:
Free gtk-clients' unit pixmap table on exit.

See bug #23862

Modified:
    branches/S2_5/client/gui-gtk-2.0/gui_main.c
    branches/S2_5/client/gui-gtk-3.0/gui_main.c

Modified: branches/S2_5/client/gui-gtk-2.0/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-2.0/gui_main.c?rev=29860&r1=29859&r2=29860&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-2.0/gui_main.c (original)
+++ branches/S2_5/client/gui-gtk-2.0/gui_main.c Fri Sep 11 17:43:43 2015
@@ -229,6 +229,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.
@@ -912,22 +914,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 (!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]);
@@ -941,6 +939,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();
 
@@ -1726,6 +1736,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_5/client/gui-gtk-3.0/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-3.0/gui_main.c?rev=29860&r1=29859&r2=29860&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-3.0/gui_main.c (original)
+++ branches/S2_5/client/gui-gtk-3.0/gui_main.c Fri Sep 11 17:43:43 2015
@@ -214,6 +214,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.
@@ -904,22 +906,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 (!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]);
@@ -933,6 +931,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();
 
@@ -1751,6 +1761,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

Reply via email to