On Feb 26, 2016, at 5:29 PM, Miklós Máté mtmkls@gmail.com wrote:
@@ -2320,6 +2322,7 @@ static BOOL X11DRV_wglDestroyPbufferARB( struct wgl_pbuffer *object ) TRACE("(%p)\n", object);
pglXDestroyPbuffer(gdi_display, object->drawable);
- pglXDestroyContext(gdi_display, object->tmp_context);
I think you need to check if object->tmp_context is non-zero before calling glXDestroyContext() to avoid a GLXBadContext error.
if (!object->tmp_context) {
object->tmp_context = pglXCreateNewContext(gdi_display, object->fmt->fbconfig, object->fmt->render_type, prev_context, True);
object->prev_context = prev_context;
} else if (object->prev_context != prev_context) {
pglXDestroyContext(gdi_display, object->tmp_context);
object->tmp_context = pglXCreateNewContext(gdi_display, object->fmt->fbconfig, object->fmt->render_type, prev_context, True);
object->prev_context = prev_context;
}
Those two branches are mostly the same. This could be reduced to:
if (!object->tmp_context || object->prev_context != prev_context) { if (object->tmp_context) pglXDestroyContext(gdi_display, object->tmp_context); object->tmp_context = pglXCreateNewContext(gdi_display, object->fmt->fbconfig, object->fmt->render_type, prev_context, True); object->prev_context = prev_context; }
Is it necessary, when a context is destroyed, to go through all wgl_pbuffer structs looking for any whose prev_context matches the one being destroyed and clear it? Otherwise, you risk having a stale reference that could be reused for a different context and not realize you need to recreate tmp_context. Of course, enumerating all of them in a thread-safe manner is going to require a lot of added infrastructure and complexity.
-Ken