diff options
author | Adam Jackson <ajax@redhat.com> | 2011-03-28 12:30:09 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2011-04-15 12:55:47 -0400 |
commit | 6a433b67ca15fd1ea58334e607f867554f227451 (patch) | |
tree | e7b7983482d4f84672ad81d2497e2cb776e6a001 /glx/glxext.c | |
parent | b3d2164a0361f636bfe77b51456bee9213af4f13 (diff) |
glx: Fix lifetime tracking for pixmaps
GLX pixmaps take a reference on the underlying pixmap; X and GLX pixmap
IDs can be destroyed in either order with no error. Only windows need
to be tracked under both XIDs.
Fixes piglit/glx-pixmap-life.
Reviewed-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'glx/glxext.c')
-rw-r--r-- | glx/glxext.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/glx/glxext.c b/glx/glxext.c index 3f3dd798f..9cfc096c3 100644 --- a/glx/glxext.c +++ b/glx/glxext.c @@ -118,15 +118,15 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) { __GLXcontext *c, *next; - /* If this drawable was created using glx 1.3 drawable - * constructors, we added it as a glx drawable resource under both - * its glx drawable ID and it X drawable ID. Remove the other - * resource now so we don't a callback for freed memory. */ - if (glxPriv->drawId != glxPriv->pDraw->id) { - if (xid == glxPriv->drawId) - FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE); - else - FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE); + if (glxPriv->type == GLX_DRAWABLE_WINDOW) { + /* If this was created by glXCreateWindow, free the matching resource */ + if (glxPriv->drawId != glxPriv->pDraw->id) { + if (xid == glxPriv->drawId) + FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE); + else + FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE); + } + /* otherwise this window was implicitly created by MakeCurrent */ } for (c = glxAllContexts; c; c = next) { @@ -143,6 +143,10 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) c->readPriv = NULL; } + /* drop our reference to any backing pixmap */ + if (glxPriv->type == GLX_DRAWABLE_PIXMAP) + glxPriv->pDraw->pScreen->DestroyPixmap((PixmapPtr)glxPriv->pDraw); + glxPriv->destroy(glxPriv); return True; |