From 20e4314b178e1a093bce85e93329d4bcfb4f4210 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 29 Mar 2007 19:12:32 +0930 Subject: dix: Try to get closer to the correct refcnt for cursors. This commit introduces a memory leak, as the refcnt never seems to get down to 0 and thus cursors will not be freed. Solves the problems with GNOME segfaulting every 30 seconds though. --- dix/cursor.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dix/cursor.c b/dix/cursor.c index c58e2fa16..27ae9f17d 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -196,11 +196,10 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, bits->height = cm->height; bits->xhot = cm->xhot; bits->yhot = cm->yhot; - bits->refcnt = -1; + pCurs->refcnt = 0; CheckForEmptyMask(bits); pCurs->bits = bits; - pCurs->refcnt = 1; #ifdef XFIXES pCurs->serialNumber = ++cursorSerial; pCurs->name = None; @@ -224,6 +223,7 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, { if (DevHasCursor(pDev)) { + pCurs->refcnt++; if (!( *pscr->RealizeCursor)(pDev, pscr, pCurs)) { /* Realize failed for device pDev on screen pscr. @@ -419,7 +419,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, } CheckForEmptyMask(bits); pCurs->bits = bits; - pCurs->refcnt = 1; + pCurs->refcnt = 0; #ifdef XFIXES pCurs->serialNumber = ++cursorSerial; pCurs->name = None; @@ -440,6 +440,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, { pscr = screenInfo.screens[nscr]; + pCurs->refcnt++; if (!(*pscr->RealizeCursor)(inputInfo.pointer, pscr, pCurs)) { DeviceIntPtr pDevIt = inputInfo.devices; /*dev iterator*/ @@ -470,6 +471,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, { if (DevHasCursor(pDev)) { + pCurs->refcnt++; if (!( *pscr->RealizeCursor)(pDev, pscr, pCurs)) { /* Realize failed for device pDev on screen pscr. -- cgit v1.2.3