gdiplus: Properly clean up the new metafile data.

This commit is contained in:
Vincent Povirk 2011-06-21 12:48:11 -05:00 committed by Alexandre Julliard
parent 42db8e2bfa
commit 698fddf99b
2 changed files with 19 additions and 1 deletions

View File

@ -2027,7 +2027,21 @@ GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
DeleteDC(((GpBitmap*)image)->hdc); DeleteDC(((GpBitmap*)image)->hdc);
DeleteObject(((GpBitmap*)image)->hbitmap); DeleteObject(((GpBitmap*)image)->hbitmap);
} }
else if (image->type != ImageTypeMetafile) else if (image->type == ImageTypeMetafile)
{
GpMetafile *metafile = (GpMetafile*)image;
GdipFree(metafile->comment_data);
DeleteEnhMetaFile(CloseEnhMetaFile(metafile->record_dc));
DeleteEnhMetaFile(metafile->hemf);
if (metafile->record_graphics)
{
WARN("metafile closed while recording\n");
/* not sure what to do here; for now just prevent the graphics from functioning or using this object */
metafile->record_graphics->image = NULL;
metafile->record_graphics->busy = TRUE;
}
}
else
{ {
WARN("invalid image: %p\n", image); WARN("invalid image: %p\n", image);
return ObjectBusy; return ObjectBusy;

View File

@ -307,6 +307,10 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
metafile->hemf = CloseEnhMetaFile(metafile->record_dc); metafile->hemf = CloseEnhMetaFile(metafile->record_dc);
metafile->record_dc = NULL; metafile->record_dc = NULL;
GdipFree(metafile->comment_data);
metafile->comment_data = NULL;
metafile->comment_data_size = 0;
return stat; return stat;
} }