[gimp] libgimpwidgets: call babl_exit() when unloading
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: call babl_exit() when unloading
- Date: Thu, 1 Jun 2017 02:15:23 +0000 (UTC)
commit e64e61ca582697849c852bc0332cb34be574a90a
Author: Ell <ell_se yahoo com>
Date: Wed May 31 21:56:07 2017 -0400
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().
configure.ac | 6 ++++++
libgimpwidgets/gimpwidgets-private.c | 23 +++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 214886c..360d2b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
#####################################################################
diff --git a/libgimpwidgets/gimpwidgets-private.c b/libgimpwidgets/gimpwidgets-private.c
index c508be1..92fd9c2 100644
--- a/libgimpwidgets/gimpwidgets-private.c
+++ b/libgimpwidgets/gimpwidgets-private.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]