Re: [evolution-patches] [calendar-alarms]fix for a crash (with patch this time :-)



forgot to attach the revised patch in previous mail  :-)

P. S. Chakravarthi
Software Engineer
pchakravarthi novell com
Phone: 25731856 Extn: 3198

Novell Inc.
Software for the Open Enterprise  

>>> "Chakravarthi P" <pchakravarthi novell com> 12/15/05 2:06 PM >>>
hi
 
     there is a crash in alarm-notifier when the option
     to quit alarms is chosen. This is due to 
     attempts in removal of hash table items with
    wrong keys and asserting if hash table is empty 
    later. Changelog explains it further.

  regards

P. S. Chakravarthi
Software Engineer
pchakravarthi novell com
Phone: 25731856 Extn: 3198

Novell Inc.
Software for the Open Enterprise  


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2872
diff -u -p -r1.2872 ChangeLog
--- ChangeLog	15 Dec 2005 08:33:18 -0000	1.2872
+++ ChangeLog	15 Dec 2005 11:56:10 -0000
@@ -1,3 +1,15 @@
+2005-12-15 P S Chakravarthi <pchakravarthi novell com>
+
+	Fixes a crash in alarm-daemon on selecting "Quit" in panel options
+	* gui/alarm-notify/alarm-queue.c  (remove_client_alarms):
+	Removed the code loops through a list of ids generated.
+	used g_hash_table_foreach instead.
+	* gui/alarm-notify/alarm-queue.c (add_id_cb) : removed.
+	* gui/alarm-notify/alarm-queue.c (remove_comp_by_id) : added
+	* gui/alarm-notify/alarm-queue.c (alarm_queue_add_client) :
+	replaced g_str_equal with g_direct_equal in g_hash_table_new
+	to consider structure pointers rather than strings for keys.
+
 2005-12-15  Chenthill Palanisamy  <pchenthill novell com>
 
 	Fixes #324058
Index: gui/alarm-notify/alarm-queue.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/alarm-notify/alarm-queue.c,v
retrieving revision 1.91
diff -u -p -r1.91 alarm-queue.c
--- gui/alarm-notify/alarm-queue.c	24 Nov 2005 15:28:11 -0000	1.91
+++ gui/alarm-notify/alarm-queue.c	15 Dec 2005 11:56:10 -0000
@@ -546,7 +546,7 @@ remove_comp (ClientAlarms *ca, const ECa
 	CompQueuedAlarms *cqa;
 
 	cqa = lookup_comp_queued_alarms (ca, id);
-	if (!cqa)
+	if (!cqa) 
 		return;
 
 	/* If a component is present, then it means we must have alarms queued
@@ -911,7 +911,7 @@ notify_dialog_cb (AlarmNotifyResult resu
 				if (!tray_data->snooze_set){
 					GList *temp = list->next;
 					tray_icons_list = g_list_remove_link (tray_icons_list, list);
-		remove_queued_alarm (tray_data->cqa, tray_data->alarm_id, TRUE, TRUE);
+					remove_queued_alarm (tray_data->cqa, tray_data->alarm_id, TRUE, TRUE);
 					free_tray_icon_data (tray_data);
 					tray_data = NULL;
 					g_list_free_1 (list);
@@ -921,7 +921,7 @@ notify_dialog_cb (AlarmNotifyResult resu
 						list = temp;
 				} else
 					list = list->next;
-	}
+			}
 	}
 
 		break;
@@ -1743,13 +1743,15 @@ compare_ids (gpointer a, gpointer b)
 
 	id = a;
 	id1 = b;
-	
-	if (g_str_equal (id->uid, id1->uid)) {
-		if (id->rid && id1->rid)
-			return g_str_equal (id->rid, id1->rid);
-		else if (!(id->rid && id1->rid))
-			return TRUE;
-	} 
+
+	if (id->uid != NULL && id1->uid != NULL) {
+		if (g_str_equal (id->uid, id1->uid)) {
+			if (id->rid && id1->rid)
+				return g_str_equal (id->rid, id1->rid);
+			else if (!(id->rid && id1->rid))
+				return TRUE;
+		} 
+	}
 	return FALSE;
 }
 
@@ -1789,7 +1791,7 @@ alarm_queue_add_client (ECal *client)
 
 	g_hash_table_insert (client_alarms_hash, client, ca);
 
-	ca->uid_alarms_hash = g_hash_table_new (g_str_hash, (GEqualFunc) compare_ids);
+	ca->uid_alarms_hash = g_hash_table_new (g_direct_hash, (GEqualFunc) compare_ids);
 
 	if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) {
 		load_alarms_for_today (ca);
@@ -1800,43 +1802,20 @@ alarm_queue_add_client (ECal *client)
 	}
 }
 
-/* Called from g_hash_table_foreach(); adds a component UID to a list */
 static void
-add_id_cb (gpointer key, gpointer value, gpointer data)
-{
-	GSList **ids = (GSList **) data;
-	ECalComponentId *id = g_new0 (ECalComponentId, 1);
-	ECalComponentId *temp = (ECalComponentId *)key;
+remove_comp_by_id (gpointer key, gpointer value, gpointer userdata) {
 
-	id->uid = g_strdup (temp->uid);
-	id->rid = g_strdup (temp->rid);
-
-	*ids = g_slist_prepend (*ids, (ECalComponentId *) id);
+	ClientAlarms *ca = (ClientAlarms *)userdata;
+	remove_comp (ca, (ECalComponentId *)key);
 }
 
+
 /* Removes all the alarms queued for a particular calendar client */
 static void
 remove_client_alarms (ClientAlarms *ca)
 {
-	GSList *ids = NULL;
-	GSList *l;
-
-	/* First we build a list of UIDs so that we can remove them one by one */
-
-	g_hash_table_foreach (ca->uid_alarms_hash, add_id_cb, &ids);
-
-	for (l = ids; l; l = l->next) {
-		const ECalComponentId *id;
-
-		id = l->data;
-
-		remove_comp (ca, id);
-	}
-
-	g_slist_free (ids);
-
+	g_hash_table_foreach (ca->uid_alarms_hash, (GHFunc)remove_comp_by_id, ca);
 	/* The hash table should be empty now */
-
 	g_assert (g_hash_table_size (ca->uid_alarms_hash) == 0);
 }
 


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