gdiplus: Give a nice warning when we try to draw to an HDC-less graphics.
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;