changeset 14122:dabbcb9b013d

[gaim-migrate @ 16759] This initializes threads for glib and dbus, because under some circumstances multithreaded libraries are causing dbus badness (namely, gnome-vfs). This fix doesn't really belong in Gaim, but in the interest of expedience (we don't want to wait for upstream libraries to get their initializations all worked around to make things safe) the fix goes here. Note that all Gaim frontends will have to initialize glib threads if other threaded libraries which interact with glib or dbus or what-have-you come into play. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Mon, 14 Aug 2006 21:46:17 +0000
parents 8af7f3a7015f
children f8ab496671fa
files configure.ac src/Makefile.am src/dbus-server.c src/gtkmain.c
diffstat 4 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Mon Aug 14 08:32:52 2006 +0000
+++ b/configure.ac	Mon Aug 14 21:46:17 2006 +0000
@@ -636,7 +636,7 @@
 AM_PATH_GLIB_2_0(2.0.0,,AC_MSG_ERROR([
 *** GLib 2.0 is required to build Gaim; please make sure you have the GLib
 *** development headers installed. The latest version of GLib is
-*** always available at http://www.gtk.org/.]))
+*** always available at http://www.gtk.org/.]),gthread)
 AM_PATH_GTK_2_0(2.0.0,,AC_MSG_ERROR([
 *** GTK+ 2.0 is required to build Gaim; please make sure you have the GTK+
 *** development headers installed. The latest version of GTK+ is
--- a/src/Makefile.am	Mon Aug 14 08:32:52 2006 +0000
+++ b/src/Makefile.am	Mon Aug 14 21:46:17 2006 +0000
@@ -339,6 +339,7 @@
 gaim_LDFLAGS = -export-dynamic
 gaim_LDADD = \
 	@LIBOBJS@ \
+	$(GLIB_LIBS) \
 	$(GTK_LIBS) \
 	$(DBUS_LIBS) \
 	$(GSTREAMER_LIBS) \
--- a/src/dbus-server.c	Mon Aug 14 08:32:52 2006 +0000
+++ b/src/dbus-server.c	Mon Aug 14 21:46:17 2006 +0000
@@ -757,6 +757,9 @@
 void
 gaim_dbus_init(void)
 {
+	if (g_thread_supported())
+		dbus_g_thread_init();
+
 	gaim_dbus_init_ids();
 
 	g_free(init_error);
--- a/src/gtkmain.c	Mon Aug 14 08:32:52 2006 +0000
+++ b/src/gtkmain.c	Mon Aug 14 21:46:17 2006 +0000
@@ -643,6 +643,15 @@
 	gtk_rc_add_default_file(search_path);
 	g_free(search_path);
 
+#if (defined(G_THREADS_ENABLED) && !defined(G_THREADS_IMPL_NONE))
+	/* Since threads can be yanked in all unawares by other libraries,
+	 * and some libraries aren't smart enough to initialize the thread
+	 * subsystem when they need it, we need to do this here.  We also
+	 * threadify dbus when that gets initialized.  Ugh. */
+	if (!g_thread_supported())
+		g_thread_init(NULL);
+	gdk_threads_init();
+#endif /* Glib has threads */
 
 	gui_check = gtk_init_check(&argc, &argv);
 	if (!gui_check) {