[PATCH] damage: Remove the 'damage window' resource type

Keith Packard keithp at keithp.com
Mon Mar 28 11:03:39 PDT 2011


On Mon, 28 Mar 2011 10:56:08 -0400, Adam Jackson <ajax at redhat.com> wrote:

> No code to create objects of this type ever existed.

I suspect that's a bug then -- the damage object is going to hang around
with a dead pointer to the window when it is destroyed.

Here's a completely untested patch that hooks the window id to the
damage record so that it is destroyed when the window is destroyed:

I think this gets the ENOMEM case right -- AddResource will call 
FreeDamageExtWin if it fails, which will call FreeResource on the damage
ID, freeing the damage structure.

diff --git a/damageext/damageext.c b/damageext/damageext.c
index 754383d..20f772b 100644
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -220,8 +220,10 @@ ProcDamageCreate (ClientPtr client)
     DamageSetReportAfterOp (pDamageExt->pDamage, TRUE);
     DamageRegister (pDamageExt->pDrawable, pDamageExt->pDamage);
 
-    if (pDrawable->type == DRAWABLE_WINDOW)
+    if (WindowDrawable(pDrawable->type))
     {
+	if (!AddResource (pDrawable->id, DamageExtWinType, (pointer) pDamageExt))
+	    return BadAlloc;
 	pRegion = &((WindowPtr) pDrawable)->borderClip;
 	DamageDamageRegion(pDrawable, pRegion);
     }

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20110328/cc8c9cb0/attachment.pgp>


More information about the xorg-devel mailing list