[evolution-patches] [patch][mail] fix for bug 357492 - crash when deletign attachments



Hi,
the patch for the bug http://bugzilla.gnome.org/show_bug.cgi?id=357492
is attached.

Please review.

Thanks and Cheers,
partha
-- 
Parthasarathi S A
ajaysusarla at gmail dot com

Where I go, I dont need a road.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/ChangeLog,v
retrieving revision 1.453
diff -u -p -r1.453 ChangeLog
--- ChangeLog	11 Oct 2006 08:26:40 -0000	1.453
+++ ChangeLog	3 Nov 2006 16:55:46 -0000
@@ -1,3 +1,12 @@
+2006-11-03  Parthasarathi Susarla <ajaysusarla gmail com>
+
+	** Fixes bug #357492
+	* e-attachment-bar.c: (e_attachment_bar_remove_selected):
+	put the attachment pointes into a temporary array. Free the
+	pointers and the array after going thru the entire list
+	This prevents a crash and also fixes the issue of only few 
+	attachments getting deleted.
+
 2006-10-11  Srinivasa Ragavan  <sragavan novell com>
 
 	** Fix for bug #360237 & bug #359236
Index: e-attachment-bar.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-attachment-bar.c,v
retrieving revision 1.24
diff -u -p -r1.24 e-attachment-bar.c
--- e-attachment-bar.c	29 Sep 2006 06:21:52 -0000	1.24
+++ e-attachment-bar.c	3 Nov 2006 16:55:46 -0000
@@ -466,7 +466,8 @@ e_attachment_bar_remove_selected (EAttac
 	EAttachment *attachment;
 	int id, left, nrem = 0;
 	GList *items;
-	
+	GPtrArray *temp_arr;
+
 	g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
 	
 	priv = bar->priv;
@@ -474,16 +475,20 @@ e_attachment_bar_remove_selected (EAttac
 	if (!(items = gnome_icon_list_get_selection ((GnomeIconList *) bar)))
 		return;
 	
+	temp_arr = g_ptr_array_new ();
 	while (items != NULL) {
 		if ((id = GPOINTER_TO_INT (items->data) - nrem) < priv->attachments->len) {
-			/* Note: this removes the item from the array due to the weak_ref callback */
-			attachment = priv->attachments->pdata[id];
-			g_object_unref (attachment);
+			attachment = E_ATTACHMENT(g_ptr_array_index (priv->attachments, id));
+			g_ptr_array_add (temp_arr, (gpointer)attachment);
+			g_ptr_array_remove_index (priv->attachments, id);
 			nrem++;
 		}
 		
 		items = items->next;
 	}
+
+	g_ptr_array_foreach (temp_arr, (GFunc)g_object_unref, NULL);
+	g_ptr_array_free (temp_arr, TRUE);
 	
 	update (bar);
 	


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