From: Andrew R. <ar...@us...> - 2006-08-31 02:06:02
|
Update of /cvsroot/plplot/plplot/drivers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20227/drivers Modified Files: wingcc.c Log Message: Fixed up the memory bug with Visual C. Seems that MingW/GCC zeros memory blocks when you call free() and Visual C doesn't, so one block was (under Visual C) being freed twice with unfortunate consequences. Index: wingcc.c =================================================================== RCS file: /cvsroot/plplot/plplot/drivers/wingcc.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- wingcc.c 21 Aug 2006 04:22:09 -0000 1.17 +++ wingcc.c 31 Aug 2006 02:05:59 -0000 1.18 @@ -148,11 +148,11 @@ * Some debugging macros \*--------------------------------------------------------------------------*/ -#ifndef __VISUALC__ +#ifdef _MSC_VER + #define Debug(a) do {if (pls->debug){fprintf(stderr,(a));}}while(0) +#else #define Verbose(...) do {if (pls->verbose){fprintf(stderr,__VA_ARGS__);}}while(0) #define Debug(...) do {if (pls->debug){fprintf(stderr,__VA_ARGS__);}}while(0) -#else - #define Debug(a) do {if (pls->debug){fprintf(stderr,(a));}}while(0) #endif #define ReportWinError() do { \ @@ -265,19 +265,19 @@ if ((dev->waiting==1)&&(dev->already_erased==1)) { - Debug("Remaking\t"); + Debug("Remaking\t"); - if (dev->ps.fErase) - { - dev->oldcolour = SetBkColor(dev->hdc, RGB(pls->cmap0[0].r,pls->cmap0[0].g,pls->cmap0[0].b)); - ExtTextOut(dev->hdc, 0, 0, ETO_OPAQUE, &dev->rect, "", 0, 0); - SetBkColor(dev->hdc, dev->oldcolour); - } + if (dev->ps.fErase) + { + dev->oldcolour = SetBkColor(dev->hdc, RGB(pls->cmap0[0].r,pls->cmap0[0].g,pls->cmap0[0].b)); + ExtTextOut(dev->hdc, 0, 0, ETO_OPAQUE, &dev->rect, "", 0, 0); + SetBkColor(dev->hdc, dev->oldcolour); + } - plRemakePlot(pls); - CopySCRtoBMP(pls); - dev->already_erased++; - } + plRemakePlot(pls); + CopySCRtoBMP(pls); + dev->already_erased++; + } else if ((dev->waiting==1)&&(dev->already_erased==2)) { dev->oldobject = SelectObject(dev->hdc2,dev->bitmap); @@ -341,7 +341,6 @@ * filling a rectangle - go figure ? */ - /*GetClientRect(dev->hdc,&dev->rect);*/ dev->oldcolour = SetBkColor(dev->hdc, RGB(pls->cmap0[0].r,pls->cmap0[0].g,pls->cmap0[0].b)); ExtTextOut(dev->hdc, 0, 0, ETO_OPAQUE, &dev->rect, "", 0, 0); SetBkColor(dev->hdc, dev->oldcolour); @@ -395,7 +394,7 @@ DrvOpt wingcc_options[] = { #ifdef HAVE_FREETYPE - {"text", DRV_INT, &freetype, "Use driver text (FreeType)"}, + {"text", DRV_INT, &freetype, "Use driver text (FreeType)"}, {"smooth", DRV_INT, &smooth_text, "Turn text smoothing on (1) or off (0)"}, {"save", DRV_INT, &save_reg, "Save defaults to registary"}, @@ -501,14 +500,14 @@ /* Color the background white */ dev->wndclass.hbrBackground = NULL; - dev->wndclass.cbWndExtra = sizeof(pls); + dev->wndclass.cbWndExtra = sizeof(pls); /* * Now register the window class for use. */ - RegisterClassEx (&dev->wndclass); + RegisterClassEx (&dev->wndclass); /* @@ -586,7 +585,6 @@ */ GetClientRect(dev->hwnd,&dev->rect); -/* GetClipBox(dev->hdc,&dev->rect); */ dev->width=dev->rect.right; dev->height=dev->rect.bottom; @@ -602,7 +600,6 @@ Debug("Scale = %f (FLT)\n",dev->scale); plP_setpxl(dev->scale*pls->xdpi/25.4,dev->scale*pls->ydpi/25.4); - plP_setphy(0, dev->scale*dev->width, 0, dev->scale*dev->height); #ifdef HAVE_FREETYPE @@ -814,6 +811,7 @@ void plD_tidy_wingcc(PLStream *pls) { + wingcc_Dev *dev = NULL; #ifdef HAVE_FREETYPE if (pls->dev_text) @@ -823,9 +821,17 @@ plD_FreeType_Destroy(pls); } #endif + Debug("plD_tidy_wingcc"); if (pls->dev!=NULL) - free(pls->dev); + { + dev = (wingcc_Dev *)pls->dev; + if (dev->hdc2!=NULL) DeleteDC(dev->hdc2); + if (dev->hdc!=NULL) ReleaseDC(dev->hwnd,dev->hdc); + if (dev->bitmap!=NULL) DeleteObject(dev->bitmap); + free_mem(pls->dev); + } + } |