Destroy the GL context after driDestroyTextureHeap, because the driver's
[mesa.git] / src / mesa / drivers / dri / r128 / r128_context.c
index 75f618ad37aed0c498c2ef018e5e575d2058b0b4..6194d128f4bb62977079a498501cecc7749d32de 100644 (file)
@@ -296,10 +296,6 @@ void r128DestroyContext( __DRIcontextPrivate *driContextPriv  )
       _ac_DestroyContext( rmesa->glCtx );
       _swrast_DestroyContext( rmesa->glCtx );
 
-      /* free the Mesa context */
-      rmesa->glCtx->DriverCtx = NULL;
-      _mesa_destroy_context(rmesa->glCtx);
-
       if ( release_texture_heaps ) {
          /* This share group is about to go away, free our private
           * texture object data.
@@ -314,6 +310,10 @@ void r128DestroyContext( __DRIcontextPrivate *driContextPriv  )
         assert( is_empty_list( & rmesa->swapped ) );
       }
 
+      /* free the Mesa context */
+      rmesa->glCtx->DriverCtx = NULL;
+      _mesa_destroy_context(rmesa->glCtx);
+
       /* free the option cache */
       driDestroyOptionCache (&rmesa->optionCache);