From 4a69c4173d6bf120b5abbcb38072fa053918d393 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen Date: Thu, 29 May 2008 11:00:06 -0600 Subject: Fix segfault on exit in unichrome driver (bug 16150) --- src/mesa/drivers/dri/unichrome/via_context.c | 56 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index bbb198bf0e8..d9b4f2d112a 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -679,46 +679,48 @@ void viaDestroyContext(__DRIcontextPrivate *driContextPriv) { GET_CURRENT_CONTEXT(ctx); - struct via_context *vmesa = + struct via_context *vmesa = (struct via_context *)driContextPriv->driverPrivate; struct via_context *current = ctx ? VIA_CONTEXT(ctx) : NULL; + assert(vmesa); /* should never be null */ + if (vmesa->driDrawable) { + viaWaitIdle(vmesa, GL_FALSE); + + if (vmesa->doPageFlip) { + LOCK_HARDWARE(vmesa); + if (vmesa->pfCurrentOffset != 0) { + fprintf(stderr, "%s - reset pf\n", __FUNCTION__); + viaResetPageFlippingLocked(vmesa); + } + UNLOCK_HARDWARE(vmesa); + } + } + /* check if we're deleting the currently bound context */ if (vmesa == current) { VIA_FLUSH_DMA(vmesa); _mesa_make_current(NULL, NULL, NULL); } - if (vmesa) { - viaWaitIdle(vmesa, GL_FALSE); - if (vmesa->doPageFlip) { - LOCK_HARDWARE(vmesa); - if (vmesa->pfCurrentOffset != 0) { - fprintf(stderr, "%s - reset pf\n", __FUNCTION__); - viaResetPageFlippingLocked(vmesa); - } - UNLOCK_HARDWARE(vmesa); - } - - _swsetup_DestroyContext(vmesa->glCtx); - _tnl_DestroyContext(vmesa->glCtx); - _vbo_DestroyContext(vmesa->glCtx); - _swrast_DestroyContext(vmesa->glCtx); - /* free the Mesa context */ - _mesa_destroy_context(vmesa->glCtx); - /* release our data */ - FreeBuffer(vmesa); + _swsetup_DestroyContext(vmesa->glCtx); + _tnl_DestroyContext(vmesa->glCtx); + _vbo_DestroyContext(vmesa->glCtx); + _swrast_DestroyContext(vmesa->glCtx); + /* free the Mesa context */ + _mesa_destroy_context(vmesa->glCtx); + /* release our data */ + FreeBuffer(vmesa); - assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_AGP])); - assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_VIDEO])); - assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_SYSTEM])); - assert (is_empty_list(&vmesa->freed_tex_buffers)); + assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_AGP])); + assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_VIDEO])); + assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_SYSTEM])); + assert (is_empty_list(&vmesa->freed_tex_buffers)); - driDestroyOptionCache(&vmesa->optionCache); + driDestroyOptionCache(&vmesa->optionCache); - FREE(vmesa); - } + FREE(vmesa); } -- cgit v1.2.3