Commit e64e61ca authored by Ell's avatar Ell

libgimpwidgets: call babl_exit() when unloading

If the compiler supports destructors (which should cover at least
GCC and Clang), pair the call to babl_init() in gimp_widgets_init()
with a call to babl_exit() when the library in unloaded.  This is
important in particular since the babl fish cache is constructed/
updated upon the last matched call to babl_exit().
parent 1176482b
......@@ -945,6 +945,12 @@ AC_CHECK_FUNC(rint, AC_DEFINE(HAVE_RINT, 1,
AC_DEFINE(HAVE_RINT)])])
##############################
# Check for attributes we need
##############################
AX_GCC_FUNC_ATTRIBUTE(destructor)
#####################################################################
# Check for extra libs needed for getaddrinfo, getnameinfo and socket
#####################################################################
......
......@@ -34,6 +34,8 @@
#include "libgimp/libgimp-intl.h"
static gboolean gimp_widgets_initialized = FALSE;
GimpHelpFunc _gimp_standard_help_func = NULL;
GimpGetColorFunc _gimp_get_foreground_func = NULL;
GimpGetColorFunc _gimp_get_background_func = NULL;
......@@ -63,8 +65,6 @@ gimp_widgets_init (GimpHelpFunc standard_help_func,
GimpGetColorFunc get_background_func,
GimpEnsureModulesFunc ensure_modules_func)
{
static gboolean gimp_widgets_initialized = FALSE;
g_return_if_fail (standard_help_func != NULL);
if (gimp_widgets_initialized)
......@@ -85,3 +85,22 @@ gimp_widgets_init (GimpHelpFunc standard_help_func,
gimp_widgets_initialized = TRUE;
}
/* clean up babl (in particular, so that the fish cache is constructed) if the
* compiler supports destructors
*/
#ifdef HAVE_FUNC_ATTRIBUTE_DESTRUCTOR
__attribute__ ((destructor))
static void
gimp_widgets_exit (void)
{
if (gimp_widgets_initialized)
babl_exit ();
}
#elif defined (__GNUC__)
#warning babl_init() not paired with babl_exit()
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment