r22538 - gnucash/branches/2.4 - [r22533]Accommodate g_threads changes in GLib-2.32 and later.

John Ralls jralls at code.gnucash.org
Tue Nov 6 19:24:42 EST 2012


Author: jralls
Date: 2012-11-06 19:24:41 -0500 (Tue, 06 Nov 2012)
New Revision: 22538
Trac: http://svn.gnucash.org/trac/changeset/22538

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

Guards older implementation with ifndef HAVE_GLIB_2_32

Modified: gnucash/branches/2.4/configure.ac
===================================================================
--- gnucash/branches/2.4/configure.ac	2012-11-07 00:24:29 UTC (rev 22537)
+++ gnucash/branches/2.4/configure.ac	2012-11-07 00:24:41 UTC (rev 22538)
@@ -253,6 +253,14 @@
   AC_MSG_RESULT(no)
   _have_glib_testing=no
 fi
+AC_MSG_CHECKING([for GLib 2.32 or later (glib >=2.32.0)])
+if $PKG_CONFIG "glib-2.0 >= 2.32.0"
+then
+  AC_MSG_RESULT(yes)
+  AC_DEFINE([HAVE_GLIB_2_32], [1], [Configure gthread deprecations])
+else
+  AC_MSG_RESULT(no)
+fi
 AM_CONDITIONAL(HAVE_GLIB_TESTING, test "x$_have_glib_testing" = "xyes")
 
 AC_CHECK_HEADERS(dirent.h dlfcn.h dl.h utmp.h locale.h mcheck.h unistd.h wctype.h)

Modified: gnucash/branches/2.4/src/backend/xml/io-gncxml-v2.c
===================================================================
--- gnucash/branches/2.4/src/backend/xml/io-gncxml-v2.c	2012-11-07 00:24:29 UTC (rev 22537)
+++ gnucash/branches/2.4/src/backend/xml/io-gncxml-v2.c	2012-11-07 00:24:41 UTC (rev 22538)
@@ -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/branches/2.4/src/bin/gnucash-bin.c
===================================================================
--- gnucash/branches/2.4/src/bin/gnucash-bin.c	2012-11-07 00:24:29 UTC (rev 22537)
+++ gnucash/branches/2.4/src/bin/gnucash-bin.c	2012-11-07 00:24:41 UTC (rev 22538)
@@ -807,8 +807,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/branches/2.4/src/gnome-utils/gnc-tree-model-account.c
===================================================================
--- gnucash/branches/2.4/src/gnome-utils/gnc-tree-model-account.c	2012-11-07 00:24:29 UTC (rev 22537)
+++ gnucash/branches/2.4/src/gnome-utils/gnc-tree-model-account.c	2012-11-07 00:24:41 UTC (rev 22538)
@@ -320,6 +320,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;
 
@@ -330,6 +331,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/branches/2.4/src/gnome-utils/gnc-tree-model-commodity.c
===================================================================
--- gnucash/branches/2.4/src/gnome-utils/gnc-tree-model-commodity.c	2012-11-07 00:24:29 UTC (rev 22537)
+++ gnucash/branches/2.4/src/gnome-utils/gnc-tree-model-commodity.c	2012-11-07 00:24:41 UTC (rev 22538)
@@ -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/branches/2.4/src/gnome-utils/gnc-tree-model-price.c
===================================================================
--- gnucash/branches/2.4/src/gnome-utils/gnc-tree-model-price.c	2012-11-07 00:24:29 UTC (rev 22537)
+++ gnucash/branches/2.4/src/gnome-utils/gnc-tree-model-price.c	2012-11-07 00:24:41 UTC (rev 22538)
@@ -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/branches/2.4/src/libqof/qof/guid.c
===================================================================
--- gnucash/branches/2.4/src/libqof/qof/guid.c	2012-11-07 00:24:29 UTC (rev 22537)
+++ gnucash/branches/2.4/src/libqof/qof/guid.c	2012-11-07 00:24:41 UTC (rev 22538)
@@ -674,6 +674,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;
 
@@ -684,6 +685,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