Author: spouliot
Date: 2006-03-20 16:10:21 -0500 (Mon, 20 Mar 2006)
New Revision: 58205

Modified:
   trunk/libgdiplus/src/ChangeLog
   trunk/libgdiplus/src/texturebrush.c
Log:
texturebrush.c: Ensure we destroy the matrix and the surface when disposing the 
brush. Add a reference to the surface when cloning.

Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog      2006-03-20 21:08:02 UTC (rev 58204)
+++ trunk/libgdiplus/src/ChangeLog      2006-03-20 21:10:21 UTC (rev 58205)
@@ -1,3 +1,8 @@
+2006-03-20  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * texturebrush.c: Ensure we destroy the matrix and the surface when
+       disposing the brush. Add a reference to the surface when cloning.
+
 2006-03-20  Sebastien Pouliot  <[EMAIL PROTECTED]> 
  
        * font.c: Re-work font locking not to leak memory (and not to create

Modified: trunk/libgdiplus/src/texturebrush.c
===================================================================
--- trunk/libgdiplus/src/texturebrush.c 2006-03-20 21:08:02 UTC (rev 58204)
+++ trunk/libgdiplus/src/texturebrush.c 2006-03-20 21:10:21 UTC (rev 58205)
@@ -364,7 +364,6 @@
        GpImage *img, *gr_img;
        GpBitmap *bmp, *gr_bmp;
        cairo_format_t format;
-       GpMatrix *product = NULL;
        unsigned int width;
        unsigned int height;
        GpStatus status = Ok;
@@ -438,12 +437,12 @@
                GdipDisposeImage((GpImage *)bmp);
        }
 
-       GdipCreateMatrix (&product);
        if (status == Ok) {
                if (texture->pattern == NULL)
                        status = GenericError;
                else {
-
+                       GpMatrix *product = NULL;
+                       GdipCreateMatrix (&product);
                /* Cairo Bug: REPEAT and transformation do not go together.     
   */
                /* To work around this we can create an intermediate surface 
first */
                /* with REPEAT and use that with transformation as a pattern. 
But, */
@@ -486,6 +485,7 @@
                        }
                        status = gdip_get_status (cairo_status (ct));
                        /*      cairo_surface_destroy (temp); */
+                       GdipDeleteMatrix (product);
                }
        }
 
@@ -507,7 +507,6 @@
        texture = (GpTexture *) brush;
        result->base = texture->base;
        result->wrapMode = texture->wrapMode;
-       result->image = texture->image;
 
        /* Let the clone create its own pattern. */
        result->pattern = NULL;
@@ -523,6 +522,9 @@
 
        memcpy (result->rectangle, texture->rectangle, sizeof (GpRect));
 
+       result->image = texture->image;
+       cairo_surface_reference (result->image->surface);
+
        *clonedBrush = (GpBrush *) result;
 
        return Ok;
@@ -537,14 +539,26 @@
 
        texture = (GpTexture *) brush;
 
-       if (texture->rectangle != NULL)
+       if (texture->rectangle) {
                GdipFree (texture->rectangle);
-       texture->rectangle = NULL;
+               texture->rectangle = NULL;
+       }
 
-       if (texture->pattern != NULL)
+       if (texture->pattern) {
                cairo_pattern_destroy (texture->pattern);
-       texture->pattern = NULL;
+               texture->pattern = NULL;
+       }
 
+       if (texture->image && texture->image->surface) {
+               cairo_surface_destroy (texture->image->surface);
+               texture->image->surface = NULL;
+       }
+
+       if (texture->matrix) {
+               GdipDeleteMatrix (texture->matrix);
+               texture->matrix = NULL;
+       }
+
        GdipFree (texture);
 
        return Ok;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to