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

oldstable
Vincent Povirk 2013-03-02 14:28:01 -06:00 committed by Alexandre Julliard
parent edea85dea6
commit 7b004c1714
2 changed files with 5 additions and 1 deletions

View File

@ -154,6 +154,7 @@ struct GpGraphics{
BOOL owndc;
BOOL alpha_hdc;
GpImage *image;
ImageType image_type;
SmoothingMode smoothing;
CompositingQuality compqual;
InterpolationMode interpolation;

View File

@ -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)