Vincent Povirk : gdiplus: Store the image type on a Graphics object in case the image is freed.

Alexandre Julliard julliard at winehq.org
Mon Mar 4 13:23:37 CST 2013


Module: wine
Branch: master
Commit: 7b004c17149af7b9bedc72ff1ee30ea6f6f755c5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7b004c17149af7b9bedc72ff1ee30ea6f6f755c5

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Sat Mar  2 14:28:01 2013 -0600

gdiplus: Store the image type on a Graphics object in case the image is freed.

---

 dlls/gdiplus/gdiplus_private.h |    1 +
 dlls/gdiplus/graphics.c        |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index cb7330e..87f3b8b 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -154,6 +154,7 @@ struct GpGraphics{
     BOOL owndc;
     BOOL alpha_hdc;
     GpImage *image;
+    ImageType image_type;
     SmoothingMode smoothing;
     CompositingQuality compqual;
     InterpolationMode interpolation;
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 853027c..1150675 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -2195,6 +2195,9 @@ GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics)
     (*graphics)->hwnd = NULL;
     (*graphics)->owndc = FALSE;
     (*graphics)->image = image;
+    /* We have to store the image type here because the image may be freed
+     * before GdipDeleteGraphics is called, and metafiles need special treatment. */
+    (*graphics)->image_type = image->type;
     (*graphics)->smoothing = SmoothingModeDefault;
     (*graphics)->compqual = CompositingQualityDefault;
     (*graphics)->interpolation = InterpolationModeBilinear;
@@ -2389,7 +2392,7 @@ GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
     if(!graphics) return InvalidParameter;
     if(graphics->busy) return ObjectBusy;
 
-    if (graphics->image && graphics->image->type == ImageTypeMetafile)
+    if (graphics->image && graphics->image_type == ImageTypeMetafile)
     {
         stat = METAFILE_GraphicsDeleted((GpMetafile*)graphics->image);
         if (stat != Ok)




More information about the wine-cvs mailing list