diff options
-rw-r--r-- | src/cairo-mutex-private.h | 8 | ||||
-rw-r--r-- | src/cairo-mutex.c | 12 | ||||
-rw-r--r-- | src/cairo-os2-surface.c | 6 |
3 files changed, 22 insertions, 4 deletions
diff --git a/src/cairo-mutex-private.h b/src/cairo-mutex-private.h index 80f5644a..73ca9b3a 100644 --- a/src/cairo-mutex-private.h +++ b/src/cairo-mutex-private.h @@ -140,11 +140,17 @@ CAIRO_BEGIN_DECLS #define CAIRO_MUTEX_INITIALIZE() do { \ if (!_cairo_mutex_initialized) \ - _cairo_mutex_initialize(); \ + _cairo_mutex_initialize (); \ +} while(0) + +#define CAIRO_MUTEX_FINALIZE() do { \ + if (_cairo_mutex_initialized) \ + _cairo_mutex_finalize (); \ } while(0) cairo_private extern cairo_bool_t _cairo_mutex_initialized; cairo_private void _cairo_mutex_initialize(void); +cairo_private void _cairo_mutex_finalize(void); #endif diff --git a/src/cairo-mutex.c b/src/cairo-mutex.c index 1dc9c933..03b08e5d 100644 --- a/src/cairo-mutex.c +++ b/src/cairo-mutex.c @@ -52,4 +52,16 @@ void _cairo_mutex_initialize (void) #undef CAIRO_MUTEX_DECLARE } +void _cairo_mutex_finalize (void) +{ + if (!_cairo_mutex_initialized) + return; + + _cairo_mutex_initialized = FALSE; + +#define CAIRO_MUTEX_DECLARE(mutex) CAIRO_MUTEX_FINI (mutex) +#include "cairo-mutex-list-private.h" +#undef CAIRO_MUTEX_DECLARE +} + #endif diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c index b2933a51..319a7aba 100644 --- a/src/cairo-os2-surface.c +++ b/src/cairo-os2-surface.c @@ -98,6 +98,8 @@ cairo_os2_init (void) /* Initialize FontConfig */ FcInit (); + + CAIRO_MUTEX_INITIALIZE (); } cairo_public void @@ -118,9 +120,7 @@ cairo_os2_fini (void) _cairo_ft_font_reset_static_data (); #endif -#define CAIRO_MUTEX_DECLARE(name) CAIRO_MUTEX_FINI(name) -#include "cairo-mutex-list-private.h" -#undef CAIRO_MUTEX_DECLARE + CAIRO_MUTEX_FINALIZE (); /* Uninitialize FontConfig */ FcFini (); |