From 0f927224fe992116c0710c9fb15ddfd7d5f6fb61 Mon Sep 17 00:00:00 2001 From: Chenthill Palanisamy Date: Mon, 3 Oct 2005 10:12:05 +0000 Subject: fixes 271480. svn path=/trunk/; revision=30473 --- calendar/ChangeLog | 7 +++++++ calendar/gui/alarm-notify/notify-main.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 7e94b4054c..c9bee9ebdb 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +2005-10-03 Chenthill Palanisamy + + 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 Fixes #264449 diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c index b6f60222b5..4dca946d76 100644 --- a/calendar/gui/alarm-notify/notify-main.c +++ b/calendar/gui/alarm-notify/notify-main.c @@ -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 (BonoboGenericFactory *factory, const char *component_id 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 (BonoboGenericFactory *factory, const char *component_id 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; } -- cgit