Fix crashes when glxMakeCurrent is called.
Signed-off-by: Gregory Hainaut <gregory.hainaut@gmail.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
free(glthread);
ctx->GLThread = NULL;
- /* Remove ourselves from the dispatch table. */
- ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
- _glapi_set_dispatch(ctx->CurrentClientDispatch);
+ /* Remove ourselves from the dispatch table except if another ctx/thread
+ * already installed a new dispatch table.
+ *
+ * Typically glxMakeCurrent will bind a new context (install new table) then
+ * old context might be deleted.
+ */
+ if (_glapi_get_dispatch() == ctx->MarshalExec) {
+ ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
+ _glapi_set_dispatch(ctx->CurrentClientDispatch);
+ }
}
void