From bb5f5dba93408b43ddafdd22cc1f47a7ae8f60de Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 27 Oct 2010 17:49:55 -0500 Subject: [PATCH] gdiplus: Make get_path_hrgn work with HDC-less graphics objects. --- dlls/gdiplus/region.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c index e9f2d9ab798..f11f3ca3669 100644 --- a/dlls/gdiplus/region.c +++ b/dlls/gdiplus/region.c @@ -884,6 +884,7 @@ GpStatus WINGDIPAPI GdipGetRegionDataSize(GpRegion *region, UINT *needed) static GpStatus get_path_hrgn(GpPath *path, GpGraphics *graphics, HRGN *hrgn) { HDC new_hdc=NULL; + GpGraphics *new_graphics=NULL; GpStatus stat; INT save_state; @@ -893,13 +894,20 @@ static GpStatus get_path_hrgn(GpPath *path, GpGraphics *graphics, HRGN *hrgn) if (!new_hdc) return OutOfMemory; - stat = GdipCreateFromHDC(new_hdc, &graphics); + stat = GdipCreateFromHDC(new_hdc, &new_graphics); + graphics = new_graphics; if (stat != Ok) { ReleaseDC(0, new_hdc); return stat; } } + else if (!graphics->hdc) + { + graphics->hdc = new_hdc = GetDC(0); + if (!new_hdc) + return OutOfMemory; + } save_state = SaveDC(graphics->hdc); EndPath(graphics->hdc); @@ -918,7 +926,10 @@ static GpStatus get_path_hrgn(GpPath *path, GpGraphics *graphics, HRGN *hrgn) if (new_hdc) { ReleaseDC(0, new_hdc); - GdipDeleteGraphics(graphics); + if (new_graphics) + GdipDeleteGraphics(new_graphics); + else + graphics->hdc = NULL; } return stat;