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>
This commit is contained in:
		
							parent
							
								
									b3d2164a03
								
							
						
					
					
						commit
						6a433b67ca
					
				|  | @ -1127,10 +1127,11 @@ DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, | ||||||
| 	return BadAlloc; | 	return BadAlloc; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* Add the glx drawable under the XID of the underlying X drawable
 |     /*
 | ||||||
|      * too.  That way we'll get a callback in DrawableGone and can |      * Windows aren't refcounted, so track both the X and the GLX window | ||||||
|      * clean up properly when the drawable is destroyed. */ |      * so we get called regardless of destruction order. | ||||||
|     if (drawableId != glxDrawableId && |      */ | ||||||
|  |     if (drawableId != glxDrawableId && type == GLX_DRAWABLE_WINDOW && | ||||||
| 	!AddResource(pDraw->id, __glXDrawableRes, pGlxDraw)) { | 	!AddResource(pDraw->id, __glXDrawableRes, pGlxDraw)) { | ||||||
| 	pGlxDraw->destroy (pGlxDraw); | 	pGlxDraw->destroy (pGlxDraw); | ||||||
| 	return BadAlloc; | 	return BadAlloc; | ||||||
|  | @ -1161,6 +1162,8 @@ DoCreateGLXPixmap(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config | ||||||
|     err = DoCreateGLXDrawable(client, pGlxScreen, config, pDraw, drawableId, |     err = DoCreateGLXDrawable(client, pGlxScreen, config, pDraw, drawableId, | ||||||
| 			      glxDrawableId, GLX_DRAWABLE_PIXMAP); | 			      glxDrawableId, GLX_DRAWABLE_PIXMAP); | ||||||
| 
 | 
 | ||||||
|  |     ((PixmapPtr)pDraw)->refcnt++; | ||||||
|  | 
 | ||||||
|     return err; |     return err; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								glx/glxext.c
								
								
								
								
							
							
						
						
									
										22
									
								
								glx/glxext.c
								
								
								
								
							|  | @ -118,15 +118,15 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) | ||||||
| { | { | ||||||
|     __GLXcontext *c, *next; |     __GLXcontext *c, *next; | ||||||
| 
 | 
 | ||||||
|     /* If this drawable was created using glx 1.3 drawable
 |     if (glxPriv->type == GLX_DRAWABLE_WINDOW) { | ||||||
|      * constructors, we added it as a glx drawable resource under both |         /* If this was created by glXCreateWindow, free the matching resource */ | ||||||
|      * its glx drawable ID and it X drawable ID.  Remove the other |         if (glxPriv->drawId != glxPriv->pDraw->id) { | ||||||
|      * resource now so we don't a callback for freed memory. */ |             if (xid == glxPriv->drawId) | ||||||
|     if (glxPriv->drawId != glxPriv->pDraw->id) { |                 FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE); | ||||||
| 	if (xid == glxPriv->drawId) |             else | ||||||
| 	    FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE); |                 FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE); | ||||||
| 	else |         } | ||||||
| 	    FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE); |         /* otherwise this window was implicitly created by MakeCurrent */ | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     for (c = glxAllContexts; c; c = next) { |     for (c = glxAllContexts; c; c = next) { | ||||||
|  | @ -143,6 +143,10 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) | ||||||
| 	    c->readPriv = NULL; | 	    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); |     glxPriv->destroy(glxPriv); | ||||||
| 
 | 
 | ||||||
|     return True; |     return True; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue