AUDIT: r22533 - gnucash/trunk - Accommodate g_threads changes in GLib-2.32 and later.

John Ralls jralls at code.gnucash.org
Tue Nov 6 16:34:04 EST 2012


Author: jralls
Date: 2012-11-06 16:34:03 -0500 (Tue, 06 Nov 2012)
New Revision: 22533
Trac: http://svn.gnucash.org/trac/changeset/22533

Modified:
   gnucash/trunk/configure.ac
   gnucash/trunk/src/backend/xml/io-gncxml-v2.c
   gnucash/trunk/src/bin/gnucash-bin.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c
   gnucash/trunk/src/libqof/qof/guid.c
Log:
Accommodate g_threads changes in GLib-2.32 and later.


Guards older implementation with ifndef HAVE_GLIB_2_32

BP


Modified: gnucash/trunk/configure.ac
===================================================================
--- gnucash/trunk/configure.ac	2012-11-05 19:49:32 UTC (rev 22532)
+++ gnucash/trunk/configure.ac	2012-11-06 21:34:03 UTC (rev 22533)
@@ -229,8 +229,15 @@
 ### --------------------------------------------------------------------------
 ### Glib checks.
 
-# We require glib >= 2.28, released together with gtk-2.24
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28 gthread-2.0 gobject-2.0 gmodule-2.0)
+# We require glib >= 2.28, released together with gtk-2.24; There are
+# some thread deprecations that affect us in 2.32, so we check for
+# that first.
+PKG_CHECK_MODULES(GLIB,
+                  glib-2.0 >= 2.32 gthread-2.0 gobject-2.0 gmodule-2.0,
+		  [AC_DEFINE([HAVE_GLIB_2_32], [1],
+		             [Configure gthread deprecations])],
+		  [PKG_CHECK_MODULES(GLIB,
+		   glib-2.0 >= 2.28 gthread-2.0 gobject-2.0 gmodule-2.0)])
 
 AC_CHECK_HEADERS(dirent.h dlfcn.h dl.h utmp.h locale.h mcheck.h unistd.h wctype.h)
 

Modified: gnucash/trunk/src/backend/xml/io-gncxml-v2.c
===================================================================
--- gnucash/trunk/src/backend/xml/io-gncxml-v2.c	2012-11-05 19:49:32 UTC (rev 22532)
+++ gnucash/trunk/src/backend/xml/io-gncxml-v2.c	2012-11-06 21:34:03 UTC (rev 22533)
@@ -1487,7 +1487,13 @@
         params->perms = g_strdup(perms);
         params->compress = compress;
 
-        thread = g_thread_create((GThreadFunc) gz_thread_func, params, TRUE, &error);
+#ifndef HAVE_GLIB_2_32
+        thread = g_thread_create((GThreadFunc) gz_thread_func, params,
+				 TRUE, &error);
+#else
+        thread = g_thread_new("xml_thread", (GThreadFunc) gz_thread_func,
+			      params);
+#endif
         if (!thread)
         {
             g_warning("Could not create thread for (de)compression: %s",

Modified: gnucash/trunk/src/bin/gnucash-bin.c
===================================================================
--- gnucash/trunk/src/bin/gnucash-bin.c	2012-11-05 19:49:32 UTC (rev 22532)
+++ gnucash/trunk/src/bin/gnucash-bin.c	2012-11-06 21:34:03 UTC (rev 22533)
@@ -824,8 +824,9 @@
 #if !defined(G_THREADS_ENABLED) || defined(G_THREADS_IMPL_NONE)
 #    error "No GLib thread implementation available!"
 #endif
+#ifndef HAVE_GLIB_2_32 /* Automatic after GLib 2-32 */
     g_thread_init(NULL);
-
+#endif
 #ifdef ENABLE_BINRELOC
     {
         GError *binreloc_error = NULL;

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c	2012-11-05 19:49:32 UTC (rev 22532)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c	2012-11-06 21:34:03 UTC (rev 22533)
@@ -321,6 +321,7 @@
 iter_to_string (GtkTreeIter *iter)
 {
 #ifdef G_THREADS_ENABLED
+#ifndef HAVE_GLIB_2_32
     static GStaticPrivate gtmits_buffer_key = G_STATIC_PRIVATE_INIT;
     gchar *string;
 
@@ -331,6 +332,17 @@
         g_static_private_set (&gtmits_buffer_key, string, g_free);
     }
 #else
+    static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
+    gchar *string;
+
+    string = g_private_get (&gtmits_buffer_key);
+    if (string == NULL)
+    {
+        string = g_malloc(ITER_STRING_LEN + 1);
+        g_private_set (&gtmits_buffer_key, string);
+    }
+#endif
+#else
     static char string[ITER_STRING_LEN + 1];
 #endif
 

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c	2012-11-05 19:49:32 UTC (rev 22532)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c	2012-11-06 21:34:03 UTC (rev 22533)
@@ -315,6 +315,7 @@
     gnc_commodity_namespace *namespace;
     gnc_commodity *commodity = NULL;
 #ifdef G_THREADS_ENABLED
+#ifndef HAVE_GLIB_2_32
     static GStaticPrivate gtmits_buffer_key = G_STATIC_PRIVATE_INIT;
     gchar *string;
 
@@ -325,6 +326,17 @@
         g_static_private_set (&gtmits_buffer_key, string, g_free);
     }
 #else
+    static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
+    gchar *string;
+
+    string = g_private_get (&gtmits_buffer_key);
+    if (string == NULL)
+    {
+        string = g_malloc(ITER_STRING_LEN + 1);
+        g_private_set (&gtmits_buffer_key, string);
+    }
+#endif
+#else
     static char string[ITER_STRING_LEN + 1];
 #endif
     if (iter)

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c	2012-11-05 19:49:32 UTC (rev 22532)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c	2012-11-06 21:34:03 UTC (rev 22533)
@@ -323,6 +323,7 @@
 iter_to_string (GtkTreeIter *iter)
 {
 #ifdef G_THREADS_ENABLED
+#ifndef HAVE_GLIB_2_32
     static GStaticPrivate gtmits_buffer_key = G_STATIC_PRIVATE_INIT;
     gchar *string;
 
@@ -333,6 +334,17 @@
         g_static_private_set (&gtmits_buffer_key, string, g_free);
     }
 #else
+    static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
+    gchar *string;
+
+    string = g_private_get (&gtmits_buffer_key);
+    if (string == NULL)
+    {
+        string = g_malloc(ITER_STRING_LEN + 1);
+        g_private_set (&gtmits_buffer_key, string);
+    }
+#endif
+#else
     static char string[ITER_STRING_LEN + 1];
 #endif
 

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c	2012-11-05 19:49:32 UTC (rev 22532)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c	2012-11-06 21:34:03 UTC (rev 22533)
@@ -379,6 +379,7 @@
     gnc_commodity *commodity;
     GNCPrice *price;
 #ifdef G_THREADS_ENABLED
+#ifndef HAVE_GLIB_2_32
     static GStaticPrivate gtmits_buffer_key = G_STATIC_PRIVATE_INIT;
     gchar *string;
 
@@ -389,6 +390,17 @@
         g_static_private_set (&gtmits_buffer_key, string, g_free);
     }
 #else
+    static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
+    gchar *string;
+
+    string = g_private_get (&gtmits_buffer_key);
+    if (string == NULL)
+    {
+        string = g_malloc(ITER_STRING_LEN + 1);
+        g_private_set (&gtmits_buffer_key, string);
+    }
+#endif
+#else
     static char string[ITER_STRING_LEN + 1];
 #endif
 

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c	2012-11-05 19:49:32 UTC (rev 22532)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c	2012-11-06 21:34:03 UTC (rev 22533)
@@ -589,6 +589,7 @@
 iter_to_string (GtkTreeIter *iter)
 {
 #ifdef G_THREADS_ENABLED
+#ifndef HAVE_GLIB_2_32
     static GStaticPrivate gtmits_buffer_key = G_STATIC_PRIVATE_INIT;
     gchar *string;
 
@@ -599,6 +600,17 @@
         g_static_private_set (&gtmits_buffer_key, string, g_free);
     }
 #else
+    static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
+    gchar *string;
+
+    string = g_private_get (&gtmits_buffer_key);
+    if (string == NULL)
+    {
+        string = g_malloc(ITER_STRING_LEN + 1);
+        g_private_set (&gtmits_buffer_key, string);
+    }
+#endif
+#else
     static char string[ITER_STRING_LEN + 1];
 #endif
 

Modified: gnucash/trunk/src/libqof/qof/guid.c
===================================================================
--- gnucash/trunk/src/libqof/qof/guid.c	2012-11-05 19:49:32 UTC (rev 22532)
+++ gnucash/trunk/src/libqof/qof/guid.c	2012-11-06 21:34:03 UTC (rev 22533)
@@ -656,6 +656,7 @@
 guid_to_string(const GncGUID * guid)
 {
 #ifdef G_THREADS_ENABLED
+#ifndef HAVE_GLIB_2_32
     static GStaticPrivate guid_buffer_key = G_STATIC_PRIVATE_INIT;
     gchar *string;
 
@@ -666,6 +667,17 @@
         g_static_private_set (&guid_buffer_key, string, g_free);
     }
 #else
+    static GPrivate guid_buffer_key = G_PRIVATE_INIT(g_free);
+    gchar *string;
+
+    string = g_private_get (&guid_buffer_key);
+    if (string == NULL)
+    {
+        string = malloc(GUID_ENCODING_LENGTH + 1);
+        g_private_set (&guid_buffer_key, string);
+    }
+#endif
+#else
     static char string[64];
 #endif
 



More information about the gnucash-changes mailing list