diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-05-15 19:01:11 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-05-15 19:17:57 +1000 |
commit | 9a5ad65330693b3273972b63d10f2907d9ab954a (patch) | |
tree | 3717cb1f7b1373bc4a1d29a03739e7b275fc61e2 /dix/cursor.c | |
parent | 35c2e263db01b2b61354298e5e85aa3cae8ac317 (diff) |
Abstract cursor refcounting
Too many callers relied on the refcnt being handled correctly. Use a simple
wrapper to handle that case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'dix/cursor.c')
-rw-r--r-- | dix/cursor.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/dix/cursor.c b/dix/cursor.c index 1ee127ac5..0820b18ad 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -114,9 +114,13 @@ FreeCursor(pointer value, XID cid) ScreenPtr pscr; DeviceIntPtr pDev = NULL; /* unused anyway */ - if (--pCurs->refcnt != 0) + + UnrefCursor(pCurs); + if (CursorRefCount(pCurs) != 0) return Success; + BUG_WARN(CursorRefCount(pCurs) < 0); + for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { pscr = screenInfo.screens[nscr]; (void) (*pscr->UnrealizeCursor) (pDev, pscr, pCurs); @@ -127,6 +131,33 @@ FreeCursor(pointer value, XID cid) return Success; } +CursorPtr +RefCursor(CursorPtr cursor) +{ + ErrorF("%s ::::: cursor is %p", __func__, cursor); + if (cursor) { + xorg_backtrace(); + cursor->refcnt++; + } + ErrorF("\n"); + return cursor; +} + +CursorPtr +UnrefCursor(CursorPtr cursor) +{ + if (cursor) + cursor->refcnt--; + return cursor; +} + +int +CursorRefCount(const CursorPtr cursor) +{ + return cursor ? cursor->refcnt : 0; +} + + /* * We check for empty cursors so that we won't have to display them */ |