X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/821ab2c68e12d85d6bb2ed8b0d48c846a65d06a0..3c0ebbe5761bd8a03c9bcf7539cb752013b0094b:/windows.c diff --git a/windows.c b/windows.c index 50ca7c2..3983d9b 100644 --- a/windows.c +++ b/windows.c @@ -177,8 +177,6 @@ static void win_status_bar(void *handle, char *text) frontend *fe = (frontend *)handle; char *rewritten; - assert(fe->drawstatus == DRAWING); - rewritten = midend_rewrite_statusbar(fe->me, text); if (!fe->laststatus || strcmp(rewritten, fe->laststatus)) { SetWindowText(fe->statusbar, rewritten); @@ -367,7 +365,6 @@ static void win_set_pen(frontend *fe, int colour, int thin) int width = thin ? 0 : fe->linewidth; print_get_colour(fe->dr, colour, &hatch, &r, &g, &b); - /* FIXME: line thickness here */ if (fe->printcolour) pen = CreatePen(PS_SOLID, width, RGB(r * 255, g * 255, b * 255)); @@ -757,12 +754,7 @@ static void win_end_page(void *handle, int number) frontend *fe = (frontend *)handle; assert(fe->drawstatus != DRAWING); - /* - * The MSDN web site sample code doesn't bother to call EndDoc - * if an error occurs half way through printing. I expect doing - * so would cause the erroneous document to actually be - * printed, or something equally undesirable. - */ + if (fe->drawstatus == NOTHING) return; @@ -790,6 +782,12 @@ static void win_end_doc(void *handle) } fe->fontstart = 0; + /* + * The MSDN web site sample code doesn't bother to call EndDoc + * if an error occurs half way through printing. I expect doing + * so would cause the erroneous document to actually be + * printed, or something equally undesirable. + */ if (fe->drawstatus == NOTHING) return; @@ -885,8 +883,10 @@ void print(frontend *fe) pd.nFromPage = pd.nToPage = 0xFFFF; pd.nMinPage = pd.nMaxPage = 1; - if (!PrintDlg(&pd)) + if (!PrintDlg(&pd)) { + document_free(doc); return; + } /* * Now pd.hDC is a device context for the printer. @@ -916,6 +916,7 @@ void print(frontend *fe) fe->drawstatus = NOTHING; DeleteDC(pd.hDC); + document_free(doc); } void deactivate_timer(frontend *fe) @@ -1114,6 +1115,7 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error) fe->brushes[i] = CreateSolidBrush(fe->colours[i]); fe->pens[i] = CreatePen(PS_SOLID, 1, fe->colours[i]); } + sfree(colours); } x = y = INT_MAX; /* find puzzle's preferred size */