From 3862bc75ec60aed9589d16d177f0e6684c8cb6d7 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Thu, 3 May 2012 23:45:07 +0100 Subject: [PATCH] glib: do not call g_thread_ functions in GLib >= 2.31 Based on downstream patch by by Christopher James Halse Rogers Should fix BXC#2329 reported by Sergey Litvinov. --- configure.ac | 5 +++++ glib/Makefile.am | 8 +++++++- glib/Thread.cs | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0335446da..b90e5af31 100644 --- a/configure.ac +++ b/configure.ac @@ -176,6 +176,11 @@ PKG_CHECK_MODULES(GIO, gio-2.0 >= $GLIB_REQUIRED_VERSION) AC_SUBST(GIO_CFLAGS) AC_SUBST(GIO_LIBS) +PKG_CHECK_MODULES(GLIB_2_31, + glib-2.0 >= 2.31, + HAVE_GLIB_2_31_OR_HIGHER=yes, HAVE_GLIB_2_31_OR_HIGHER=no) +AM_CONDITIONAL(DISABLE_GTHREAD_CHECK, test "x$HAVE_GLIB_2_31_OR_HIGHER" = "xyes") + PKG_CHECK_MODULES(PANGO, pango) AC_SUBST(PANGO_CFLAGS) AC_SUBST(PANGO_LIBS) diff --git a/glib/Makefile.am b/glib/Makefile.am index d10c3ba20..c1f82f4b8 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -81,9 +81,15 @@ EXTRA_DIST = \ glib-sharp-3.0.pc.in \ glib-api.xml +if DISABLE_GTHREAD_CHECK +BUILD_DEFINES=-define:DISABLE_GTHREAD_CHECK +else +BUILD_DEFINES= +endif + $(ASSEMBLY): $(build_sources) $(SNK) @rm -f $(ASSEMBLY).mdb - $(CSC) $(CSFLAGS) -keyfile:$(SNK) -unsafe -out:$(ASSEMBLY) -target:library $(references) $(build_sources) + $(CSC) $(CSFLAGS) -keyfile:$(SNK) -unsafe -out:$(ASSEMBLY) -target:library $(references) $(build_sources) $(BUILD_DEFINES) policy.%.config: $(top_builddir)/policy.config sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@ diff --git a/glib/Thread.cs b/glib/Thread.cs index 7ce2ce21a..249dd048e 100644 --- a/glib/Thread.cs +++ b/glib/Thread.cs @@ -28,6 +28,18 @@ namespace GLib { private Thread () {} +#if DISABLE_GTHREAD_CHECK + public static void Init () + { + // GLib automatically inits threads in 2.31 and above + // http://developer.gnome.org/glib/unstable/glib-Deprecated-Thread-APIs.html#g-thread-init + } + + public static bool Supported + { + get { return true; } + } +#else [DllImport ("libgthread-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] static extern void g_thread_init (IntPtr i); @@ -45,5 +57,7 @@ namespace GLib return g_thread_get_initialized (); } } +#endif + } }