evolution r36803 - in trunk/calendar: . gui



Author: mcrha
Date: Wed Nov 19 12:11:50 2008
New Revision: 36803
URL: http://svn.gnome.org/viewvc/evolution?rev=36803&view=rev

Log:
2008-11-19  Milan Crha  <mcrha redhat com>

	** Fix for bug #556224

	* gui/gnome-cal.c: (struct _GnomeCalendarPrivate), (setup_widgets),
	(update_todo_view_async), (update_todo_view), (gnome_calendar_init),
	(gnome_calendar_destroy): Run always 'update_todo_view' in a separate
	thread and guard its body with a mutex.

	* gui/gnome-cal.c: (update_query_async): Do not leak.



Modified:
   trunk/calendar/ChangeLog
   trunk/calendar/gui/gnome-cal.c

Modified: trunk/calendar/gui/gnome-cal.c
==============================================================================
--- trunk/calendar/gui/gnome-cal.c	(original)
+++ trunk/calendar/gui/gnome-cal.c	Wed Nov 19 12:11:50 2008
@@ -194,6 +194,9 @@
 	/* We should know which calendar has been used to create object, so store it here
 	   before emitting "user_created" signal and make it NULL just after the emit. */
 	ECal *user_created_cal;
+
+	/* used in update_todo_view, to prevent interleaving when called in separate thread */
+	GMutex *todo_update_lock;
 };
 
 /* Signal IDs */
@@ -885,6 +888,8 @@
 
 	real_sexp = adjust_e_cal_view_sexp (gcal, priv->sexp);
 	if (!real_sexp) {
+		g_object_unref (msg->gcal);
+		g_slice_free (struct _date_query_msg, msg);
 		return; /* No time range is set, so don't start a query */
 	}
 	
@@ -1304,18 +1309,30 @@
 	set_timezone (calendar);
 }
 
+struct _mupdate_todo_msg {
+	Message header;
+	GnomeCalendar *gcal;
+};
+
 static void
-update_todo_view (GnomeCalendar *gcal)
+update_todo_view_async (struct _mupdate_todo_msg *msg)
 {
+	GnomeCalendar *gcal;
 	GnomeCalendarPrivate *priv;
 	ECalModel *model;
 	char *sexp = NULL;
 
+	g_return_if_fail (msg != NULL);
+
+	gcal = msg->gcal;
 	priv = gcal->priv;
 
+	g_mutex_lock (priv->todo_update_lock);
+
 	/* Set the query on the task pad */
 	if (priv->todo_sexp) {
 		g_free (priv->todo_sexp);
+		priv->todo_sexp = NULL;
 	}
 
 	model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
@@ -1330,6 +1347,22 @@
 		e_cal_model_set_search_query (model, priv->todo_sexp);
 	}
 
+	g_mutex_unlock (priv->todo_update_lock);
+
+	g_object_unref (msg->gcal);
+	g_slice_free (struct _mupdate_todo_msg, msg);
+}
+
+static void
+update_todo_view (GnomeCalendar *gcal)
+{
+	struct _mupdate_todo_msg *msg;
+
+	msg = g_slice_new0 (struct _mupdate_todo_msg);
+	msg->header.func = (MessageFunc) update_todo_view_async;
+	msg->gcal = g_object_ref (gcal);
+
+	message_push ((Message *) msg);
 }
 
 static void
@@ -1661,7 +1694,7 @@
 				     "TaskPad", NULL);
 	e_calendar_table_load_state (E_CALENDAR_TABLE (priv->todo), filename);
 
-	update_todo_view (gcal);
+	/* update_todo_view (gcal); */
 	g_free (filename);
 
 	etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo));
@@ -1828,6 +1861,8 @@
 
 	e_categories_register_change_listener (G_CALLBACK (categories_changed_cb), gcal);
 
+	priv->todo_update_lock = g_mutex_new ();
+
 	priv->current_view_type = GNOME_CAL_DAY_VIEW;
 	priv->range_selected = FALSE;
 	priv->lview_select_daten_range = TRUE;
@@ -2004,6 +2039,8 @@
 		g_signal_handlers_disconnect_by_func (cal_model,
 				G_CALLBACK (view_done_cb), gcal);
 
+		g_mutex_free (priv->todo_update_lock);
+
 		g_free (priv);
 		gcal->priv = NULL;
 	}



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