From: Pekka Paalanen Date: Tue, 3 Jan 2012 09:58:34 +0000 (+0200) Subject: compositor-x11: improve x11_destroy() X-Git-Tag: 0.85.0~124^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43c61d83735a5fe3b6284451cb9383d3c2aa005c;p=platform%2Fupstream%2Fweston.git compositor-x11: improve x11_destroy() Free many things we were leaking before: - input device - EGL resources - xcb event source - X Display Fixes lots of Valgrind leaks. Signed-off-by: Pekka Paalanen --- diff --git a/compositor/compositor-x11.c b/compositor/compositor-x11.c index b2f4a7b..fe3f9a0 100644 --- a/compositor/compositor-x11.c +++ b/compositor/compositor-x11.c @@ -100,6 +100,17 @@ x11_input_create(struct x11_compositor *c) return 0; } +static void +x11_input_destroy(struct x11_compositor *compositor) +{ + struct x11_input *input = container_of(compositor->base.input_device, + struct x11_input, + base.input_device); + + wlsc_input_device_fini(&input->base); + free(input); +} + static int x11_compositor_init_egl(struct x11_compositor *c) { @@ -163,6 +174,17 @@ x11_compositor_init_egl(struct x11_compositor *c) return 0; } +static void +x11_compositor_fini_egl(struct x11_compositor *compositor) +{ + eglMakeCurrent(compositor->base.display, + EGL_NO_SURFACE, EGL_NO_SURFACE, + EGL_NO_CONTEXT); + + eglTerminate(compositor->base.display); + eglReleaseThread(); +} + static int x11_output_prepare_render(struct wlsc_output *output_base) { @@ -745,8 +767,16 @@ x11_compositor_get_resources(struct x11_compositor *c) static void x11_destroy(struct wlsc_compositor *ec) { - wlsc_compositor_shutdown(ec); + struct x11_compositor *compositor = (struct x11_compositor *)ec; + + wl_event_source_remove(compositor->xcb_source); + x11_input_destroy(compositor); + + wlsc_compositor_shutdown(ec); /* destroys outputs, too */ + + x11_compositor_fini_egl(compositor); + XCloseDisplay(compositor->dpy); free(ec); }