mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Accommodate g_threads changes in GLib-2.32 and later.
Guards older implementation with ifndef HAVE_GLIB_2_32 BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22533 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
ab5a701a00
commit
fd47f981ab
11
configure.ac
11
configure.ac
@ -229,8 +229,15 @@ fi
|
||||
### --------------------------------------------------------------------------
|
||||
### 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)
|
||||
|
||||
|
@ -1487,7 +1487,13 @@ try_gz_open (const char *filename, const char *perms, gboolean use_gzip,
|
||||
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",
|
||||
|
@ -824,8 +824,9 @@ main(int argc, char ** argv)
|
||||
#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;
|
||||
|
@ -321,6 +321,7 @@ static const gchar *
|
||||
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 @@ iter_to_string (GtkTreeIter *iter)
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_static_private_set (>mits_buffer_key, string, g_free);
|
||||
}
|
||||
#else
|
||||
static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
|
||||
gchar *string;
|
||||
|
||||
string = g_private_get (>mits_buffer_key);
|
||||
if (string == NULL)
|
||||
{
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_private_set (>mits_buffer_key, string);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
static char string[ITER_STRING_LEN + 1];
|
||||
#endif
|
||||
|
@ -315,6 +315,7 @@ iter_to_string (GtkTreeIter *iter)
|
||||
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;
|
||||
|
||||
@ -324,6 +325,17 @@ iter_to_string (GtkTreeIter *iter)
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_static_private_set (>mits_buffer_key, string, g_free);
|
||||
}
|
||||
#else
|
||||
static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
|
||||
gchar *string;
|
||||
|
||||
string = g_private_get (>mits_buffer_key);
|
||||
if (string == NULL)
|
||||
{
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_private_set (>mits_buffer_key, string);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
static char string[ITER_STRING_LEN + 1];
|
||||
#endif
|
||||
|
@ -323,6 +323,7 @@ static const gchar *
|
||||
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;
|
||||
|
||||
@ -332,6 +333,17 @@ iter_to_string (GtkTreeIter *iter)
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_static_private_set (>mits_buffer_key, string, g_free);
|
||||
}
|
||||
#else
|
||||
static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
|
||||
gchar *string;
|
||||
|
||||
string = g_private_get (>mits_buffer_key);
|
||||
if (string == NULL)
|
||||
{
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_private_set (>mits_buffer_key, string);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
static char string[ITER_STRING_LEN + 1];
|
||||
#endif
|
||||
|
@ -379,6 +379,7 @@ iter_to_string (GncTreeModelPrice *model, GtkTreeIter *iter)
|
||||
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;
|
||||
|
||||
@ -388,6 +389,17 @@ iter_to_string (GncTreeModelPrice *model, GtkTreeIter *iter)
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_static_private_set (>mits_buffer_key, string, g_free);
|
||||
}
|
||||
#else
|
||||
static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
|
||||
gchar *string;
|
||||
|
||||
string = g_private_get (>mits_buffer_key);
|
||||
if (string == NULL)
|
||||
{
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_private_set (>mits_buffer_key, string);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
static char string[ITER_STRING_LEN + 1];
|
||||
#endif
|
||||
|
@ -589,6 +589,7 @@ static const gchar *
|
||||
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;
|
||||
|
||||
@ -598,6 +599,17 @@ iter_to_string (GtkTreeIter *iter)
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_static_private_set (>mits_buffer_key, string, g_free);
|
||||
}
|
||||
#else
|
||||
static GPrivate gtmits_buffer_key = G_PRIVATE_INIT(g_free);
|
||||
gchar *string;
|
||||
|
||||
string = g_private_get (>mits_buffer_key);
|
||||
if (string == NULL)
|
||||
{
|
||||
string = g_malloc(ITER_STRING_LEN + 1);
|
||||
g_private_set (>mits_buffer_key, string);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
static char string[ITER_STRING_LEN + 1];
|
||||
#endif
|
||||
|
@ -656,6 +656,7 @@ const char *
|
||||
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;
|
||||
|
||||
@ -665,6 +666,17 @@ guid_to_string(const GncGUID * guid)
|
||||
string = malloc(GUID_ENCODING_LENGTH + 1);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user