[evolution-patches] fix for the bug #271480 [calendar]



Hi,
  Have attached the fix for the bug. This is to make sure alarm_notify
object is created only once.

thanks, Chenthill.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2802.2.19
diff -u -p -r1.2802.2.19 ChangeLog
--- ChangeLog	3 Oct 2005 06:12:19 -0000	1.2802.2.19
+++ ChangeLog	3 Oct 2005 09:33:29 -0000
@@ -1,3 +1,10 @@
+2005-10-03  Chenthill Palanisamy  <pchenthill novell com>
+
+	Fixes #271480
+	* gui/alarm-notify/notify-main.c: (alarm_notify_factory_fn),
+	(init_alarm_service): Added a global static mutex to ensure 
+	the alarm_notify object is created only once.
+
 2005-10-03  Mubeen Jukaku  <jmubeen novell com>
 
 	Fixes #264449
Index: gui/alarm-notify/notify-main.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/alarm-notify/notify-main.c,v
retrieving revision 1.46
diff -u -p -r1.46 notify-main.c
--- gui/alarm-notify/notify-main.c	25 Aug 2005 10:26:28 -0000	1.46
+++ gui/alarm-notify/notify-main.c	3 Oct 2005 09:33:29 -0000
@@ -52,6 +52,8 @@ static BonoboGenericFactory *factory;
 
 static AlarmNotify *alarm_notify_service = NULL;
 
+/* to ensure alarm_notify object is created only once */
+GStaticMutex mutex_init = G_STATIC_MUTEX_INIT;
 
 /* Callback for the master client's "die" signal.  We must terminate the daemon
  * since the session is ending.
@@ -104,6 +106,7 @@ init_session (void)
 static BonoboObject *
 alarm_notify_factory_fn (BonoboGenericFactory *factory, const char *component_id, void *data)
 {
+	g_static_mutex_lock (&mutex_init);
 	if (!alarm_notify_service) {
 		alarm_notify_service = alarm_notify_new ();
 		g_assert (alarm_notify_service != NULL);
@@ -111,6 +114,7 @@ alarm_notify_factory_fn (BonoboGenericFa
 
 	bonobo_object_ref (BONOBO_OBJECT (alarm_notify_service));
 
+	g_static_mutex_unlock (&mutex_init);
 	return BONOBO_OBJECT (alarm_notify_service);
 }
 
@@ -118,10 +122,13 @@ alarm_notify_factory_fn (BonoboGenericFa
 static gboolean
 init_alarm_service (gpointer user_data)
 {
+	if (!g_static_mutex_trylock (&mutex_init))
+		return FALSE;
 	if (!alarm_notify_service) {
 		alarm_notify_service = alarm_notify_new ();
 		g_assert (alarm_notify_service != NULL);
 	}
+	g_static_mutex_unlock (&mutex_init);
 	
 	return FALSE;
 }


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