Index: xrender.c =================================================================== RCS file: /cvstrees/crossover/office/wine/dlls/x11drv/xrender.c,v retrieving revision 1.2 retrieving revision 1.7 diff -u -r1.2 -r1.7 --- xrender.c 1 Feb 2002 18:12:24 -0000 1.2 +++ xrender.c 7 Mar 2002 15:51:51 -0000 1.7 @@ -67,6 +67,20 @@ static int antialias = 1; /*********************************************************************** + * stack_kludge + * + * XRender will succeed if an automatic variable has a non zero value. + * This kludge makes that more likely; we do minor tricks to attempt + * to make sure we don't get optimized away. + * + */ +static void stack_kludge(void) +{ + volatile char clearme[20000]; + memset((char *) clearme, 1, sizeof(clearme)); +} + +/*********************************************************************** * X11DRV_XRender_Init * * Let's see if our XServer has the extension available @@ -81,6 +95,32 @@ X11DRV_XRender_Installed = TRUE; TRACE("Xrender is up and running error_base = %d\n", error_base); screen_format = TSXRenderFindVisualFormat(gdi_display, visual); + + /*-------------------------------------------------------------------- + ** Xrender.c bug. (Version 1.4 of Xrender.c had a bug where + ** an uninitialized stack variable could cause this to fail. + ** This is fixed in version 1.5, which seems to correspond to + ** Xfree >= 4.2 + ** In the mean time, we do a total kludge to attempt to address this: + ** we call it twice, and pray that the second time it is + ** initialized (and nudge the stack while we're at it). + ** If it doesn't, we just bail. + ** JPW 02/12/02 + **------------------------------------------------------------------*/ + if (! screen_format) + { + WARN("XRenderFindVisualFormat failed; likely XFree bug. Retrying with stack kludge.\n"); + stack_kludge(); + screen_format = TSXRenderFindVisualFormat(gdi_display, visual); + } + if (! screen_format) + { + ERR("Your version of X has a buggy XRender extension (need >= 4.2). Disabling XRENDER.\n"); + X11DRV_XRender_Installed = FALSE; + return; + } + + pf.type = PictTypeDirect; pf.depth = 1; pf.direct.alpha = 0; @@ -354,7 +394,7 @@ return; }