[evolution-patches] 61571 crash when clicking to edit another appointment when already editing an appointment



This is a little fragile but it should work, it uses the comp_data as
the invariant to find the event again, we don't worry about our event
being reloaded because unfocussing the other event can only remove that
event.

-JP
-- 
JP Rosevear <jpr novell com>
Novell, Inc.
? 61571-2.patch
? 61571.patch
? 61760.patch
? gui/scroll.patch
? gui/select-auto.patch
? gui/select.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2455
diff -u -r1.2455 ChangeLog
--- ChangeLog	22 Jul 2004 18:11:24 -0000	1.2455
+++ ChangeLog	23 Jul 2004 14:23:20 -0000
@@ -1,3 +1,11 @@
+2004-07-22  JP Rosevear  <jpr ximian com>
+
+	Fixes #61571
+	
+	* gui/e-week-view.c (e_week_view_start_editing_event): if the
+	event moves, find it again using the model data as the invariant
+	and then find the span again
+
 2004-07-16  Larry Ewing  <lewing ximian com>
 
 	* gui/e-meeting-time-sel.c (e_meeting_time_selector_style_set):
Index: gui/e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.218
diff -u -r1.218 e-week-view.c
--- gui/e-week-view.c	16 Jul 2004 14:30:49 -0000	1.218
+++ gui/e-week-view.c	23 Jul 2004 14:23:21 -0000
@@ -2848,7 +2848,8 @@
 	EWeekViewEventSpan *span;
 	ETextEventProcessor *event_processor = NULL;
 	ETextEventProcessorCommand command;
-
+	ECalModelComponent *comp_data;
+	
 	/* If we are already editing the event, just return. */
 	if (event_num == week_view->editing_event_num
 	    && span_num == week_view->editing_span_num)
@@ -2868,11 +2869,28 @@
 				       NULL);
 	}
 
-	/* FIXME: This implicitly stops any edit of another item, causing it
-	   to be sent to the server and resulting in a call to obj_updated_cb()
-	   which may reload all the events and so our span and text item may
-	   actually be destroyed. So we often get a SEGV. */
+	/* Save the comp_data value because we use that as our invariant */
+	comp_data = event->comp_data;
+	
 	e_canvas_item_grab_focus (span->text_item, TRUE);
+	
+	/* If the above focus caused things to redraw, then find the
+	 * the event and the span again */
+	if (event_num < week_view->events->len)
+		event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
+	
+	if (event_num >= week_view->events->len || event->comp_data != comp_data) {
+		/* Unfocussing can cause a removal but not a new
+		 * addition so just run backwards through the
+		 * events */
+		for (event_num--; event_num >= 0; event_num--){
+			event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
+			if (event->comp_data == comp_data)
+				break;
+		}
+		g_assert (event_num >= 0);		
+	}	
+	span = &g_array_index (week_view->spans, EWeekViewEventSpan,  event->spans_index + span_num);
 
 	/* Try to move the cursor to the end of the text. */
 	g_object_get (G_OBJECT (span->text_item), "event_processor", &event_processor, NULL);


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