[tracker/gconf-dbus: 12/15] libtracker-common: Ensure that the default mainloop is used for the DBus connection



commit 4a83958c6a6c672a6774f70f70779a44d2fd9a6f
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon Apr 4 15:12:59 2011 +0200

    libtracker-common: Ensure that the default mainloop is used for the DBus connection

 src/libtracker-common/tracker-locale-gconfdbus.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-locale-gconfdbus.c b/src/libtracker-common/tracker-locale-gconfdbus.c
index 4d75bb7..abb3b89 100644
--- a/src/libtracker-common/tracker-locale-gconfdbus.c
+++ b/src/libtracker-common/tracker-locale-gconfdbus.c
@@ -301,9 +301,15 @@ tracker_locale_gconfdbus_init (void)
 
 		g_message ("Retrieving locale from GConf is ENABLED");
 
+		/* We want to use this connection globally, so make sure it uses the
+		 * default mainloop */
+
+		g_main_context_push_thread_default (NULL);
+
 		connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
 
 		if (error) {
+			g_main_context_pop_thread_default (NULL);
 			g_critical ("%s", error->message);
 			g_clear_error (&error);
 			return;
@@ -333,8 +339,10 @@ tracker_locale_gconfdbus_init (void)
 				g_object_unref (connection);
 				connection = NULL;
 				maemo_mode = FALSE;
+				g_main_context_pop_thread_default (NULL);
 				return;
 			} else {
+				g_main_context_pop_thread_default (NULL);
 				g_critical ("%s", error->message);
 				g_clear_error (&error);
 				return;
@@ -348,6 +356,7 @@ tracker_locale_gconfdbus_init (void)
 		introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, &error);
 
 		if (error) {
+			g_main_context_pop_thread_default (NULL);
 			g_critical ("%s", error->message);
 			g_clear_error (&error);
 			return;
@@ -365,6 +374,7 @@ tracker_locale_gconfdbus_init (void)
 		if (error) {
 			g_critical ("%s", error->message);
 			g_clear_error (&error);
+			g_main_context_pop_thread_default (NULL);
 			return;
 		}
 
@@ -374,6 +384,8 @@ tracker_locale_gconfdbus_init (void)
 		                                                on_gconfd_dbus_appeared,
 		                                                on_gconfd_dbus_disappeared,
 		                                                NULL, NULL);
+
+		g_main_context_pop_thread_default (NULL);
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]