Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] (PR#2365) gui-gtk: free_sprite doesn't free mask
Home

[Freeciv-Dev] (PR#2365) gui-gtk: free_sprite doesn't free mask

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2365) gui-gtk: free_sprite doesn't free mask
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Tue, 19 Nov 2002 16:26:57 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[jdorje - Tue Nov 19 22:57:19 2002]:

> The free_sprite() function in the GTK client doesn't free the sprite's 
> mask.  This means a certain amount of memory leak will be unavoidable, 
> especially when switching tilesets.
> 
> The attached patch seems like it would work.  But it doesn't - sometimes 
> I get the warning:
> 
> Gdk-CRITICAL **: file gdkpixmap.c: line 823 (gdk_pixmap_unref): 
> assertion `private->ref_count > 0' failed.
> 
> indicating that perhaps the mask has already been freed.  I have not 
> been able to figure out why this happens.

Here is a (possibly) better patch.

jason


? client/gui-gtk/diff
Index: client/gui-gtk/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/graphics.c,v
retrieving revision 1.47
diff -u -r1.47 graphics.c
--- client/gui-gtk/graphics.c   2002/11/14 09:14:53     1.47
+++ client/gui-gtk/graphics.c   2002/11/20 00:25:13
@@ -341,7 +341,10 @@
 ***************************************************************************/
 void free_sprite(SPRITE *s)
 {
-  gdk_imlib_free_pixmap(s->pixmap);
+  gdk_pixmap_unref(s->pixmap);
+  if (s->has_mask) {
+    gdk_pixmap_unref(s->mask);
+  }
   free(s);
   return;
 }

[Prev in Thread] Current Thread [Next in Thread]