Vincent Povirk : gdiplus: Give a nice warning when we try to draw to an HDC-less graphics.
Alexandre Julliard
julliard at winehq.org
Tue Aug 17 11:31:11 CDT 2010
Module: wine
Branch: master
Commit: c3ca6be2b9e51faeb2469ed2d064e49a88c02cee
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c3ca6be2b9e51faeb2469ed2d064e49a88c02cee
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Sun Aug 8 15:34:23 2010 -0500
gdiplus: Give a nice warning when we try to draw to an HDC-less graphics.
---
dlls/gdiplus/graphics.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 86 insertions(+), 1 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index ced0d40..ccec25d 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -94,10 +94,17 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
{
HPEN gdipen;
REAL width;
- INT save_state = SaveDC(graphics->hdc), i, numdashes;
+ INT save_state, i, numdashes;
GpPointF pt[2];
DWORD dash_array[MAX_DASHLEN];
+ if (!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ }
+
+ save_state = SaveDC(graphics->hdc);
+
EndPath(graphics->hdc);
if(pen->unit == UnitPixel){
@@ -1973,6 +1980,11 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
if (image->picture)
{
+ if (!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ }
+
/* FIXME: partially implemented (only works for rectangular parallelograms) */
if(srcUnit == UnitInch)
dx = dy = (REAL) INCH_HIMETRIC;
@@ -2772,6 +2784,12 @@ GpStatus WINGDIPAPI GdipFillEllipse(GpGraphics *graphics, GpBrush *brush, REAL x
if(graphics->busy)
return ObjectBusy;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return Ok;
+ }
+
ptf[0].X = x;
ptf[0].Y = y;
ptf[1].X = x + width;
@@ -2814,6 +2832,12 @@ GpStatus WINGDIPAPI GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *p
if(graphics->busy)
return ObjectBusy;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return Ok;
+ }
+
save_state = SaveDC(graphics->hdc);
EndPath(graphics->hdc);
SetPolyFillMode(graphics->hdc, (path->fill == FillModeAlternate ? ALTERNATE
@@ -2851,6 +2875,12 @@ GpStatus WINGDIPAPI GdipFillPie(GpGraphics *graphics, GpBrush *brush, REAL x,
if(graphics->busy)
return ObjectBusy;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return Ok;
+ }
+
save_state = SaveDC(graphics->hdc);
EndPath(graphics->hdc);
@@ -2890,6 +2920,12 @@ GpStatus WINGDIPAPI GdipFillPolygon(GpGraphics *graphics, GpBrush *brush,
if(graphics->busy)
return ObjectBusy;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return Ok;
+ }
+
ptf = GdipAlloc(count * sizeof(GpPointF));
pti = GdipAlloc(count * sizeof(POINT));
if(!ptf || !pti){
@@ -2937,6 +2973,12 @@ GpStatus WINGDIPAPI GdipFillPolygonI(GpGraphics *graphics, GpBrush *brush,
if(graphics->busy)
return ObjectBusy;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return Ok;
+ }
+
ptf = GdipAlloc(count * sizeof(GpPointF));
pti = GdipAlloc(count * sizeof(POINT));
if(!ptf || !pti){
@@ -3002,6 +3044,12 @@ GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush,
if(graphics->busy)
return ObjectBusy;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return Ok;
+ }
+
ptf[0].X = x;
ptf[0].Y = y;
ptf[1].X = x + width;
@@ -3042,6 +3090,12 @@ GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush,
if(graphics->busy)
return ObjectBusy;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return Ok;
+ }
+
ptf[0].X = x;
ptf[0].Y = y;
ptf[1].X = x + width;
@@ -3134,6 +3188,12 @@ GpStatus WINGDIPAPI GdipFillRegion(GpGraphics* graphics, GpBrush* brush,
if(graphics->busy)
return ObjectBusy;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return Ok;
+ }
+
status = GdipGetRegionHRgn(region, graphics, &hrgn);
if(status != Ok)
return status;
@@ -3744,6 +3804,12 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
if (regionCount < stringFormat->range_count)
return InvalidParameter;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return NotImplemented;
+ }
+
if (stringFormat->attr)
TRACE("may be ignoring some format flags: attr %x\n", stringFormat->attr);
@@ -3813,6 +3879,12 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
if(!graphics || !string || !font || !rect || !bounds)
return InvalidParameter;
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return NotImplemented;
+ }
+
if(linesfilled) *linesfilled = 0;
if(codepointsfitted) *codepointsfitted = 0;
@@ -3886,6 +3958,12 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string
return NotImplemented;
}
+ if(!graphics->hdc)
+ {
+ FIXME("graphics object has no HDC\n");
+ return NotImplemented;
+ }
+
if(format){
TRACE("may be ignoring some format flags: attr %x\n", format->attr);
@@ -4549,6 +4627,13 @@ GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
if(graphics->busy)
return ObjectBusy;
+ if (!graphics->hdc)
+ {
+ WARN("no HDC for this graphics\n");
+ *hdc = NULL;
+ return GenericError;
+ }
+
*hdc = graphics->hdc;
graphics->busy = TRUE;
More information about the wine-cvs
mailing list