Author: cazfi
Date: Sat Oct 24 21:38:49 2015
New Revision: 30189

URL: http://svn.gna.org/viewcvs/freeciv?rev=30189&view=rev
Log:
Fixed gtk3-client Editor icons memory leak. This was an real accumulating leak 
over
tileset and ruleset changes. It might still miss clean freeing of the last used 
icons when
the program quits.

See bug #23955

Modified:
    trunk/client/gui-gtk-3.0/editgui.c

Modified: trunk/client/gui-gtk-3.0/editgui.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/editgui.c?rev=30189&r1=30188&r2=30189&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/editgui.c  (original)
+++ trunk/client/gui-gtk-3.0/editgui.c  Sat Oct 24 21:38:49 2015
@@ -765,6 +765,28 @@
 }
 
 /****************************************************************************
+  Clear icons from tool store, and the store itself.
+****************************************************************************/
+static void clear_tool_store(GtkListStore *store)
+{
+  GtkTreeIter iter;
+  GtkTreeModel *model = GTK_TREE_MODEL(store);
+
+  if (gtk_tree_model_get_iter_first(model, &iter)) {
+    do {
+      GdkPixbuf *pixbuf;
+
+      gtk_tree_model_get(model, &iter, TVS_COL_IMAGE, &pixbuf, -1);
+      if (pixbuf != NULL) {
+        g_object_unref(pixbuf);
+      }
+    } while (gtk_tree_model_iter_next(model, &iter));
+  }
+
+  gtk_list_store_clear(store);
+}
+
+/****************************************************************************
   Reload all tool value data from the tileset for the given toolbar.
 ****************************************************************************/
 static void editbar_reload_tileset(struct editbar *eb)
@@ -779,12 +801,11 @@
     return;
   }
 
-
   /* Reload terrains. */
 
   tvs = eb->tool_selectors[ETT_TERRAIN];
   store = tvs->store;
-  gtk_list_store_clear(store);
+  clear_tool_store(store);
 
   terrain_type_iterate(pterrain) {
     gtk_list_store_append(store, &iter);
@@ -804,7 +825,7 @@
 
   tvs = eb->tool_selectors[ETT_TERRAIN_RESOURCE];
   store = tvs->store;
-  gtk_list_store_clear(store);
+  clear_tool_store(store);
 
   resource_type_iterate(presource) {
     gtk_list_store_append(store, &iter);
@@ -827,7 +848,7 @@
 
   tvs = eb->tool_selectors[ETT_TERRAIN_SPECIAL];
   store = tvs->store;
-  gtk_list_store_clear(store);
+  clear_tool_store(store);
 
   extra_type_by_cause_iterate(EC_SPECIAL, spe) {
     gtk_list_store_append(store, &iter);
@@ -846,7 +867,7 @@
 
   tvs = eb->tool_selectors[ETT_ROAD];
   store = tvs->store;
-  gtk_list_store_clear(store);
+  clear_tool_store(store);
 
   road_type_iterate(proad) {
     int id;
@@ -869,7 +890,7 @@
 
   tvs = eb->tool_selectors[ETT_MILITARY_BASE];
   store = tvs->store;
-  gtk_list_store_clear(store);
+  clear_tool_store(store);
 
   base_type_iterate(pbase) {
     int id;
@@ -893,7 +914,7 @@
 
   tvs = eb->tool_selectors[ETT_UNIT];
   store = tvs->store;
-  gtk_list_store_clear(store);
+  clear_tool_store(store);
 
   unit_type_iterate(putype) {
     gtk_list_store_append(store, &iter);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to