mirror of https://github.com/GNOME/gimp.git
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().
This commit is contained in:
parent
1176482b4b
commit
e64e61ca58
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue