From 599030c8fe3b60e9b23d6dab5e62122c8331ef6f Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Wed, 18 Dec 2013 15:39:37 -0800 Subject: Make destructors called explicitly rather than through callbacks While Cairo has callback support for the destructor, there's not an analogous way to do this with Skia, so instead of trying to be clever let's just build explicit destruction in. --- src/cairo-glx.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'src/cairo-glx.cpp') diff --git a/src/cairo-glx.cpp b/src/cairo-glx.cpp index a684d09..4c6fffc 100644 --- a/src/cairo-glx.cpp +++ b/src/cairo-glx.cpp @@ -5,18 +5,11 @@ #include "glx.h" -static void -cleanup (void *data) -{ - glx_state_t *state = (glx_state_t*)data; - destroyGLXContextAndWindow(state); - free(state); -} +static glx_state_t *state; cairo_surface_t * create_cairo_surface_glx (int width, int height) { - glx_state_t *state; cairo_device_t *cairo_device; cairo_surface_t *cairo_surface; @@ -28,6 +21,7 @@ create_cairo_surface_glx (int width, int height) if (!createGLXContextAndWindow(state, width, height)) { warnx ("Could not create GLX context and window\n"); + cleanup_state_glx(state); return NULL; } @@ -37,17 +31,13 @@ create_cairo_surface_glx (int width, int height) state->window, width, height); - if (cairo_device_set_user_data (cairo_device, - (cairo_user_data_key_t *) cleanup, - state, - cleanup)) - { - warnx ("Failed to setup cleanup callback closure\n"); - cleanup (state); - return NULL; - } - cairo_device_destroy (cairo_device); return cairo_surface; } + +void +destroy_cairo_glx(void) +{ + cleanup_state_glx(state); +} -- cgit v1.3.1-4-g156e