$NetBSD: patch-e_data_cal_factory_c,v 1.2 2016/01/31 07:01:55 richard Exp $

Replace deprecated g_atomic_int_exchange_and_add()
1886d3d0573388aa5c13af99f714687ba6a66ec6

The e-calendar-factory process did not terminate automatically
when the user logged out of the graphical desktop environment, and
e-calendar-factory thus redundantly consumed system resources.
(https://bugzilla.redhat.com/show_bug.cgi?id=1141760 and upstream
https://bugzilla.gnome.org/show_bug.cgi?id=646117)

--- calendar/libedata-cal/e-data-cal-factory.c.orig	2011-04-21 19:36:35.000000000 +0000
+++ calendar/libedata-cal/e-data-cal-factory.c
@@ -245,7 +245,7 @@ construct_cal_factory_path (void)
 
 	return g_strdup_printf (
 		"/org/gnome/evolution/dataserver/calendar/%d/%u",
-		getpid (), g_atomic_int_exchange_and_add (&counter, 1));
+		getpid (), g_atomic_int_add (&counter, 1));
 }
 
 static gboolean
@@ -863,6 +863,12 @@ on_name_lost (GDBusConnection *connectio
 		g_list_foreach (copy, remove_data_cal_cb, NULL);
 		g_list_free (copy);
 	}
+
+	if (g_strcmp0 (name, E_DATA_CAL_FACTORY_SERVICE_NAME) == 0) {
+		g_print ("Quitting on the D-Bus name lost...\n");
+		g_main_loop_quit (loop);
+	}
+ 
 }
 
 gint
