diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2013-12-18 15:39:37 -0800 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2013-12-18 15:39:37 -0800 |
| commit | 599030c8fe3b60e9b23d6dab5e62122c8331ef6f (patch) | |
| tree | 855f90b650aa636ccc0473d808276638f8ce25f3 /src/cairo-glx.cpp | |
| parent | efdd7f7835e281cea9d6955696593361b5067c21 (diff) | |
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.
Diffstat (limited to 'src/cairo-glx.cpp')
| -rw-r--r-- | src/cairo-glx.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
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); +} |