Skip to content

egl/dri2: only take a dri2_dpy reference when binding a new context/surfaces

Frank Binns requested to merge (removed):makecurrent_fix into master

This effectively reverts part of 2907faee, which changed dri2_make_current() to always take a dri2_dpy reference regardless of whether or not a new context or surface(s) were being bound. This led to a reference count imbalance as there was no corresponding code added to drop a reference on the dri2_dpy. As a consequence, any application that called eglInitialize() on a default/native display after having called eglTerminate() would always get back the old dri2_dpy, inheriting its previous state.

As the reference count is there to prevent the dri2_dpy from being destroyed between eglTerminate() and eglInitialize() calls when a context is still bound, a reference should only be taken when a successful call to dri2_dpy->core->bindContext() has been made. Fix the issue by restoring the old reference counting behaviour.

Fixes: 2907faee "egl/dri2: try to bind old context if bindContext failed" Signed-off-by: Frank Binns frank.binns@imgtec.com

Merge request reports