aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify/alarm-queue.c
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2003-03-10 19:53:36 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2003-03-10 19:53:36 +0800
commit6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2 (patch)
treee781beaf534ee8f97a4d9e2389ce93dfffe4e689 /calendar/gui/alarm-notify/alarm-queue.c
parentc8a1141a55840d16dca6fc863d8fbab7d0b4ab26 (diff)
downloadgsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.gz
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.bz2
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.lz
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.xz
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.zst
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.zip
if we already have the client loaded, don't remove it, just increment its
2003-03-09 Rodrigo Moya <rodrigo@ximian.com> * gui/alarm-notify/alarm-notify.c (alarm_notify_add_calendar): if we already have the client loaded, don't remove it, just increment its reference count. * gui/alarm-notify/alarm-queue.c (remove_queued_alarm): added new argument to specify whether we want the component's structure removed if no more alarms exist, and only free the structure if TRUE. (remove_alarms): added same new argument and pass it over to remove_queued_alarm. (remove_comp, obj_updated_cb): passed new argument to remove_alarms. (procedure_notification): passed new argument to remove_queued_alarm. (obj_removed_cb): set all freed pointers to NULL. (notify_dialog_cb): only remove the alarm if the pointers are not NULL. svn path=/trunk/; revision=20232
Diffstat (limited to 'calendar/gui/alarm-notify/alarm-queue.c')
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 50a36fe4f1..58f3429ab6 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -192,7 +192,7 @@ lookup_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id)
* the last one listed for the component, it removes the component itself.
*/
static void
-remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id)
+remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, gboolean free_object)
{
QueuedAlarm *qa;
const char *uid;
@@ -221,14 +221,16 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id)
if (cqa->queued_alarms != NULL)
return;
- cal_component_get_uid (cqa->alarms->comp, &uid);
- g_hash_table_remove (cqa->parent_client->uid_alarms_hash, uid);
- cqa->parent_client = NULL;
-
- cal_component_alarms_free (cqa->alarms);
- cqa->alarms = NULL;
-
- g_free (cqa);
+ if (free_object) {
+ cal_component_get_uid (cqa->alarms->comp, &uid);
+ g_hash_table_remove (cqa->parent_client->uid_alarms_hash, uid);
+ cqa->parent_client = NULL;
+ cal_component_alarms_free (cqa->alarms);
+ g_free (cqa);
+ } else {
+ cal_component_alarms_free (cqa->alarms);
+ cqa->alarms = NULL;
+ }
}
/* Callback used when an alarm triggers */
@@ -424,7 +426,7 @@ lookup_comp_queued_alarms (ClientAlarms *ca, const char *uid)
}
static void
-remove_alarms (CompQueuedAlarms *cqa)
+remove_alarms (CompQueuedAlarms *cqa, gboolean free_object)
{
GSList *l;
@@ -440,7 +442,7 @@ remove_alarms (CompQueuedAlarms *cqa)
l = l->next;
alarm_remove (qa->alarm_id);
- remove_queued_alarm (cqa, qa->alarm_id);
+ remove_queued_alarm (cqa, qa->alarm_id, free_object);
}
}
@@ -460,7 +462,7 @@ remove_comp (ClientAlarms *ca, const char *uid)
*/
g_assert (cqa->queued_alarms != NULL);
- remove_alarms (cqa);
+ remove_alarms (cqa, TRUE);
/* The list should be empty now, and thus the queued component alarms
* structure should have been freed and removed from the hash table.
@@ -503,7 +505,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
GSList *l;
/* if already in the list, just update it */
- remove_alarms (cqa);
+ remove_alarms (cqa, FALSE);
cqa->alarms = alarms;
cqa->queued_alarms = NULL;
@@ -664,8 +666,11 @@ on_dialog_obj_removed_cb (CalClient *client, const char *uid, gpointer data)
cal_component_get_uid (c->comp, &our_uid);
g_return_if_fail (our_uid && *our_uid);
- if (!strcmp (uid, our_uid))
+ if (!strcmp (uid, our_uid)) {
alarm_notify_dialog_disable_buttons (c->dialog);
+ c->cqa = NULL;
+ c->alarm_id = NULL;
+ }
}
/* Callback used from the alarm notify dialog */
@@ -698,7 +703,8 @@ notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data)
g_assert_not_reached ();
}
- remove_queued_alarm (c->cqa, c->alarm_id);
+ if (c->cqa != NULL)
+ remove_queued_alarm (c->cqa, c->alarm_id, TRUE);
g_object_unref (c->comp);
g_object_unref (c->client);
g_free (c);
@@ -935,7 +941,7 @@ procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id
if (result < 0)
goto fallback;
- remove_queued_alarm (cqa, alarm_id);
+ remove_queued_alarm (cqa, alarm_id, TRUE);
return;
fallback: