From 7b004c17149af7b9bedc72ff1ee30ea6f6f755c5 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sat, 2 Mar 2013 14:28:01 -0600 Subject: [PATCH] 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 deletion(-) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index cb7330ef88a..87f3b8b0e5b 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 853027c9f1a..1150675acb9 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)