[Evolution-hackers] [RFC] Make e-{addressbook, calendar}-factory automatically quit when superseded



I have lost count of the number of times I've been trying to debug
something in e-calendar-factory, but the factory I'm running in gdb is
*not* the one that's actually being used.

Sometimes I forget to kill the old factory. Sometimes I *do* kill it,
but Evolution, *while* complaining that calendars will never work again,
automatically starts a replacement (that it will never use).

This patch should allow replacement simply by running a new factory
process. This will upset Evolution, because its existing factory will go
away. But users should never be doing that anyway; this is only for
debugging. And it should make debugging a *lot* easier.

Comments?

diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index b8aa145..4779d82 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -574,6 +574,8 @@ on_name_lost (GDBusConnection *connection,
 	}
 
 	g_mutex_unlock (factory->priv->connections_lock);
+	g_print ("Superseded...\n");
+	g_main_loop_quit (loop);
 }
 
 #ifndef G_OS_WIN32
@@ -667,7 +669,7 @@ main (gint argc, gchar **argv)
 
 	owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
 		ADDRESS_BOOK_DBUS_SERVICE_NAME,
-		G_BUS_NAME_OWNER_FLAGS_NONE,
+		G_BUS_NAME_OWNER_FLAGS_REPLACE | G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT,
 		on_bus_acquired,
 		on_name_acquired,
 		on_name_lost,
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index 0b02e42..3af0ab6 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -891,6 +891,8 @@ on_name_lost (GDBusConnection *connection,
 		g_list_foreach (copy, remove_data_cal_cb, NULL);
 		g_list_free (copy);
 	}
+	g_print ("Superseded...\n");
+	g_main_loop_quit (loop);
 }
 
 #ifndef G_OS_WIN32
@@ -992,7 +994,7 @@ main (gint argc, gchar **argv)
 
 	owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
 		CALENDAR_DBUS_SERVICE_NAME,
-		G_BUS_NAME_OWNER_FLAGS_NONE,
+		G_BUS_NAME_OWNER_FLAGS_REPLACE | G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT,
 		on_bus_acquired,
 		on_name_acquired,
 		on_name_lost,


-- 
dwmw2




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