[PATCH v2 2/3] gdiplus: Report error for brush_fill_path().
Zhiyi Zhang
zzhang at codeweavers.com
Mon Jun 18 09:02:08 CDT 2018
Operation should be skipped if SelectClipPath() returns any
error. And we should report unexpected error to the caller.
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
dlls/gdiplus/graphics.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 894e879233..030019cb4b 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -1050,8 +1050,10 @@ static BOOL brush_can_fill_path(GpBrush *brush, BOOL is_fill)
}
}
-static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
+static GpStatus brush_fill_path(GpGraphics *graphics, GpBrush *brush)
{
+ DWORD error;
+ GpStatus status = Ok;
switch (brush->bt)
{
case BrushTypeSolidColor:
@@ -1064,13 +1066,25 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
RECT rc;
/* partially transparent fill */
- SelectClipPath(graphics->hdc, RGN_AND);
+ if (!SelectClipPath(graphics->hdc, RGN_AND))
+ {
+ error = GetLastError();
+ if (error == ERROR_CAN_NOT_COMPLETE)
+ status = GenericError;
+ else if (error == ERROR_INVALID_PARAMETER)
+ status = InvalidParameter;
+ else if (error == ERROR_NOT_ENOUGH_MEMORY)
+ status = OutOfMemory;
+ DeleteObject(bmp);
+ break;
+ }
if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
{
HDC hdc = CreateCompatibleDC(NULL);
if (!hdc)
{
+ status = OutOfMemory;
DeleteObject(bmp);
break;
}
@@ -1091,7 +1105,11 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
HBRUSH gdibrush, old_brush;
gdibrush = create_gdi_brush(brush);
- if (!gdibrush) return;
+ if (!gdibrush)
+ {
+ status = OutOfMemory;
+ break;
+ }
old_brush = SelectObject(graphics->hdc, gdibrush);
FillPath(graphics->hdc);
@@ -1100,6 +1118,8 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
break;
}
}
+
+ return status;
}
static BOOL brush_can_fill_pixels(GpBrush *brush)
@@ -4205,7 +4225,7 @@ static GpStatus GDI32_GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath
if(retval == Ok)
{
EndPath(graphics->hdc);
- brush_fill_path(graphics, brush);
+ retval = brush_fill_path(graphics, brush);
}
gdi_transform_release(graphics);
@@ -4511,13 +4531,13 @@ static GpStatus GDI32_GdipFillRegion(GpGraphics* graphics, GpBrush* brush,
Rectangle(graphics->hdc, rc.left, rc.top, rc.right, rc.bottom);
EndPath(graphics->hdc);
- brush_fill_path(graphics, brush);
+ status = brush_fill_path(graphics, brush);
}
RestoreDC(graphics->hdc, save_state);
- return Ok;
+ return status;
}
static GpStatus SOFTWARE_GdipFillRegion(GpGraphics *graphics, GpBrush *brush,
--
2.17.1
More information about the wine-devel
mailing list