diff --git a/src/compositor-android.c b/src/compositor-android.c index 4f56c34a..50c66e64 100644 --- a/src/compositor-android.c +++ b/src/compositor-android.c @@ -423,6 +423,8 @@ android_init_egl(struct android_compositor *compositor, static void android_fini_egl(struct android_compositor *compositor) { + gles2_renderer_destroy(&compositor->base); + eglMakeCurrent(compositor->base.egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); diff --git a/src/compositor-drm.c b/src/compositor-drm.c index 178fe285..0faf45c0 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -2034,6 +2034,8 @@ drm_destroy(struct weston_compositor *ec) weston_compositor_shutdown(ec); + gles2_renderer_destroy(ec); + /* Work around crash in egl_dri2.c's dri2_make_current() */ eglMakeCurrent(ec->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c index adc863e5..d665641d 100644 --- a/src/compositor-wayland.c +++ b/src/compositor-wayland.c @@ -797,6 +797,8 @@ wayland_restore(struct weston_compositor *ec) static void wayland_destroy(struct weston_compositor *ec) { + gles2_renderer_destroy(ec); + weston_compositor_shutdown(ec); free(ec); diff --git a/src/compositor-x11.c b/src/compositor-x11.c index 2974d478..7ec56fff 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -273,6 +273,8 @@ x11_compositor_init_egl(struct x11_compositor *c) static void x11_compositor_fini_egl(struct x11_compositor *compositor) { + gles2_renderer_destroy(&compositor->base); + eglMakeCurrent(compositor->base.egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); diff --git a/src/compositor.c b/src/compositor.c index 47d0ec5a..ce7f4245 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -3142,9 +3142,6 @@ int main(int argc, char *argv[]) wl_signal_emit(&ec->destroy_signal, ec); - if (ec->has_bind_display) - ec->unbind_display(ec->egl_display, display); - for (i = ARRAY_LENGTH(signals); i;) wl_event_source_remove(signals[--i]); diff --git a/src/compositor.h b/src/compositor.h index 763decc3..fd066e26 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -803,5 +803,7 @@ weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode int gles2_renderer_init(struct weston_compositor *ec); +void +gles2_renderer_destroy(struct weston_compositor *ec); #endif diff --git a/src/gles2-renderer.c b/src/gles2-renderer.c index 470076ba..f1941e67 100644 --- a/src/gles2-renderer.c +++ b/src/gles2-renderer.c @@ -1039,6 +1039,13 @@ struct gles2_renderer { struct weston_renderer base; }; +WL_EXPORT void +gles2_renderer_destroy(struct weston_compositor *ec) +{ + if (ec->has_bind_display) + ec->unbind_display(ec->egl_display, ec->wl_display); +} + WL_EXPORT int gles2_renderer_init(struct weston_compositor *ec) {