GDI_CheckNotLock strikes again

Huw D M Davies h.davies1 at physics.ox.ac.uk
Thu Sep 13 11:04:58 CDT 2001


On Thu, Sep 13, 2001 at 05:49:56PM +0900, Dmitry Timoshkov wrote:
> Hello.
> 
> Decided to try sample program which uses GetGlyphOutline.
> 
> Backtrace:
> =>0 0x400d2ae1 (_CheckNotSysLevel+0x51(lock=0x407bb6a4) [syslevel.c:153] in libntdll.so) (ebp=405b6734)
>   1 0x407a2667 (GDI_CheckNotLock+0x1b [gdiobj.c:446] in libgdi32.so) (ebp=405b6744)
>   2 0x40798a1c (DeleteDC+0x48(hdc=0x8bc) [dc.c:784] in libgdi32.so) (ebp=405b6764)
>   3 0x407983b9 (RestoreDC+0x13d(hdc=0x8a0, level=0x1) [dc.c:541] in libgdi32.so) (ebp=405b6790)
>   4 0x4078ba4b (PATH_StrokePath+0x28b(dc=0x403a1640, pPath=0x403a16a0) [path.c:1511] in libgdi32.so) (ebp=405b67b4)

Does this help?

Huw.
-------------- next part --------------
Index: graphics/path.c
===================================================================
RCS file: /home/wine/wine/graphics/path.c,v
retrieving revision 1.22
diff -u -r1.22 path.c
--- graphics/path.c	2001/07/02 19:59:48	1.22
+++ graphics/path.c	2001/09/13 14:53:04
@@ -1465,6 +1465,11 @@
 {
     INT i;
     POINT ptLastMove = {0,0};
+    POINT ptViewportOrg, ptWindowOrg;
+    SIZE szViewportExt, szWindowExt;
+    DWORD mapMode, graphicsMode;
+    XFORM xform;
+    BOOL ret = TRUE;
 
     if(dc->funcs->pStrokePath)
         return dc->funcs->pStrokePath(dc);
@@ -1472,10 +1477,20 @@
     if(pPath->state != PATH_Closed)
         return FALSE;
 
-    SaveDC(dc->hSelf);
+    /* Save the mapping mode info */
+    mapMode=GetMapMode(dc->hSelf);
+    GetViewportExtEx(dc->hSelf, &szViewportExt);
+    GetViewportOrgEx(dc->hSelf, &ptViewportOrg);
+    GetWindowExtEx(dc->hSelf, &szWindowExt);
+    GetWindowOrgEx(dc->hSelf, &ptWindowOrg);
+    GetWorldTransform(dc->hSelf, &xform);
+      
+    /* Set MM_TEXT */
     SetMapMode(dc->hSelf, MM_TEXT);
     SetViewportOrgEx(dc->hSelf, 0, 0, NULL);
     SetWindowOrgEx(dc->hSelf, 0, 0, NULL);
+
+
     for(i = 0; i < pPath->numEntriesUsed; i++) {
         switch(pPath->pFlags[i]) {
 	case PT_MOVETO:
@@ -1495,20 +1510,36 @@
 	    if(pPath->pFlags[i+1] != PT_BEZIERTO || 
 	       (pPath->pFlags[i+2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) {
 	        ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
-		return FALSE;
+		ret = FALSE;
+		goto end;
 	    }
 	    PolyBezierTo(dc->hSelf, &pPath->pPoints[i], 3);
 	    i += 2;
 	    break;
 	default:
 	    ERR("Got path flag %d\n", (INT)pPath->pFlags[i]);
-	    return FALSE;
+	    ret = FALSE;
+	    goto end;
 	}
 	if(pPath->pFlags[i] & PT_CLOSEFIGURE)
 	    LineTo(dc->hSelf, ptLastMove.x, ptLastMove.y);
     }
-    RestoreDC(dc->hSelf , -1);
-    return TRUE;
+
+ end:
+
+    /* Restore the old mapping mode */
+    SetMapMode(dc->hSelf, mapMode);
+    SetViewportExtEx(dc->hSelf, szViewportExt.cx, szViewportExt.cy, NULL);
+    SetViewportOrgEx(dc->hSelf, ptViewportOrg.x, ptViewportOrg.y, NULL);
+    SetWindowExtEx(dc->hSelf, szWindowExt.cx, szWindowExt.cy, NULL);
+    SetWindowOrgEx(dc->hSelf, ptWindowOrg.x, ptWindowOrg.y, NULL);
+
+    /* Go to GM_ADVANCED temporarily to restore the world transform */
+    graphicsMode=GetGraphicsMode(dc->hSelf);
+    SetGraphicsMode(dc->hSelf, GM_ADVANCED);
+    SetWorldTransform(dc->hSelf, &xform);
+    SetGraphicsMode(dc->hSelf, graphicsMode);
+    return ret;
 }
 
 


More information about the wine-devel mailing list