Skip to content

Commit

Permalink
Patch to rootless code that should fix many crashes. Credit to Ken Th…
Browse files Browse the repository at this point in the history
…omases

at CodeWeavers for the patch.  From his description:

Fix a display bug with the X server.  The Generic Rootless extension
installs overrides for certain GC (graphics context) operations.  Within
these overrides, they temporarily uninstall themselves, perform their work,
and then reinstall themselves.  Except sometimes they would return early
and wouldn't reinstall themselves when they should.  Now they do in all cases.

Fix a bug in RootlessCopyWindow where early returns could leave the screen's
dispatch table entry for CopyWindow unwrapped.  We think that this is
another case (hopefully the last) of the rootless drawing bug.
  • Loading branch information
Ben Byer authored and Jeremy Huddleston committed Nov 19, 2007
1 parent 9c30b6b commit 8606c76
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
50 changes: 32 additions & 18 deletions miext/rootless/rootlessGC.c
Expand Up @@ -412,10 +412,12 @@ static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
#define GC_IS_ROOT(pDst) ((pDst)->type == DRAWABLE_WINDOW \
&& IsRoot ((WindowPtr) (pDst)))

#define GC_SKIP_ROOT(pDst) \
#define GC_SKIP_ROOT(pDst, pGC) \
do { \
if (GC_IS_ROOT (pDst)) \
if (GC_IS_ROOT (pDst)) { \
GCOP_WRAP(pGC); \
return; \
} \
} while (0)


Expand All @@ -425,7 +427,7 @@ RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("fill spans start ");

if (nInit <= 0) {
Expand Down Expand Up @@ -481,7 +483,7 @@ RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
int nspans, int sorted)
{
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("set spans start ");

if (nspans <= 0) {
Expand Down Expand Up @@ -532,7 +534,7 @@ RootlessPutImage(DrawablePtr dst, GCPtr pGC,
BoxRec box;

GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("put image start ");

RootlessStartDrawing((WindowPtr) dst);
Expand Down Expand Up @@ -564,7 +566,10 @@ RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
GCOP_UNWRAP(pGC);

if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
{
GCOP_WRAP(pGC);
return NULL; /* nothing exposed */
}

RL_DEBUG_MSG("copy area start (src 0x%x, dst 0x%x)", pSrc, dst);

Expand Down Expand Up @@ -614,7 +619,10 @@ static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst,
GCOP_UNWRAP(pGC);

if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
{
GCOP_WRAP(pGC);
return NULL; /* nothing exposed */
}

RL_DEBUG_MSG("copy plane start ");

Expand Down Expand Up @@ -651,7 +659,7 @@ static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC,
int mode, int npt, DDXPointPtr pptInit)
{
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("polypoint start ");

RootlessStartDrawing((WindowPtr) dst);
Expand Down Expand Up @@ -745,7 +753,7 @@ static void RootlessPolylines(DrawablePtr dst, GCPtr pGC,
int mode, int npt, DDXPointPtr pptInit)
{
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("poly lines start ");

RootlessStartDrawing((WindowPtr) dst);
Expand Down Expand Up @@ -820,7 +828,7 @@ static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC,
int nseg, xSegment *pSeg)
{
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("poly segment start (win 0x%x)", dst);

RootlessStartDrawing((WindowPtr) dst);
Expand Down Expand Up @@ -891,7 +899,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
int nRects, xRectangle *pRects)
{
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("poly rectangle start ");

RootlessStartDrawing((WindowPtr) dst);
Expand Down Expand Up @@ -952,7 +960,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs)
{
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("poly arc start ");

RootlessStartDrawing((WindowPtr) dst);
Expand Down Expand Up @@ -1008,7 +1016,7 @@ static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("fill poly start (win 0x%x, fillStyle 0x%x)", dst,
pGC->fillStyle);

Expand Down Expand Up @@ -1082,7 +1090,7 @@ static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("fill rect start (win 0x%x, fillStyle 0x%x)", dst,
pGC->fillStyle);

Expand Down Expand Up @@ -1137,7 +1145,7 @@ static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("fill arc start ");

if (narcsInit > 0) {
Expand Down Expand Up @@ -1192,7 +1200,7 @@ static void RootlessImageText8(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("imagetext8 start ");

if (count > 0) {
Expand Down Expand Up @@ -1246,7 +1254,10 @@ static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC,
GCOP_UNWRAP(pGC);

if (GC_IS_ROOT(dst))
{
GCOP_WRAP(pGC);
return 0;
}

RL_DEBUG_MSG("polytext8 start ");

Expand Down Expand Up @@ -1284,7 +1295,7 @@ static void RootlessImageText16(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("imagetext16 start ");

if (count > 0) {
Expand Down Expand Up @@ -1338,7 +1349,10 @@ static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC,
GCOP_UNWRAP(pGC);

if (GC_IS_ROOT(dst))
{
GCOP_WRAP(pGC);
return 0;
}

RL_DEBUG_MSG("polytext16 start ");

Expand Down Expand Up @@ -1377,7 +1391,7 @@ static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("imageglyph start ");

if (nglyphInit > 0) {
Expand Down Expand Up @@ -1438,7 +1452,7 @@ static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
CharInfoPtr *ppci, pointer pglyphBase)
{
GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("polyglyph start ");

RootlessStartDrawing((WindowPtr) dst);
Expand Down Expand Up @@ -1484,7 +1498,7 @@ RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst,
BoxRec box;

GCOP_UNWRAP(pGC);
GC_SKIP_ROOT(dst);
GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("push pixels start ");

RootlessStartDrawing((WindowPtr) dst);
Expand Down
5 changes: 3 additions & 2 deletions miext/rootless/rootlessWindow.c
Expand Up @@ -838,13 +838,13 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
top = TopLevelParent(pWin);
if (top == NULL) {
RL_DEBUG_MSG("no parent\n");
return;
goto out;
}

winRec = WINREC(top);
if (winRec == NULL) {
RL_DEBUG_MSG("not framed\n");
return;
goto out;
}

/* Move region to window local coords */
Expand All @@ -867,6 +867,7 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
RootlessDamageRegion(pWin, prgnSrc);
}

out:
REGION_UNINIT(pScreen, &rgnDst);
fbValidateDrawable(&pWin->drawable);

Expand Down

0 comments on commit 8606c76

Please sign in to comment.