[evolution-data-server] Bug #635673 - Stack overflow when opening slow calendar



commit 9a7e29d58f56fac73369958e2c79731422003772
Author: Milan Crha <mcrha redhat com>
Date:   Wed Nov 24 14:27:41 2010 +0100

    Bug #635673 - Stack overflow when opening slow calendar

 calendar/libecal/e-cal.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index fce2778..b94d8f9 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -1358,7 +1358,7 @@ e_cal_open (ECal *ecal, gboolean only_if_exists, GError **error)
 struct idle_async_error_reply_data
 {
 	ECal *ecal; /* ref-ed */
-	GError *error; /* cannot be NULL */
+	GError *error; /* can be NULL */
 };
 
 static gboolean
@@ -1368,17 +1368,32 @@ idle_async_error_reply_cb (gpointer user_data)
 
 	g_return_val_if_fail (data != NULL, FALSE);
 	g_return_val_if_fail (data->ecal != NULL, FALSE);
-	g_return_val_if_fail (data->error != NULL, FALSE);
 
 	async_open_report_result (data->ecal, data->error);
 
 	g_object_unref (data->ecal);
-	g_error_free (data->error);
+	if (data->error)
+		g_error_free (data->error);
 	g_free (data);
 
 	return FALSE;
 }
 
+/* takes ownership of error */
+static void
+async_report_idle (ECal *ecal, GError *error)
+{
+	struct idle_async_error_reply_data *data;
+
+	g_return_if_fail (ecal != NULL);
+
+	data = g_new0 (struct idle_async_error_reply_data, 1);
+	data->ecal = g_object_ref (ecal);
+	data->error = error;
+
+	g_idle_add (idle_async_error_reply_cb, data);
+}
+
 /**
  * e_cal_open_async:
  * @ecal: A calendar client.
@@ -1413,20 +1428,10 @@ e_cal_open_async (ECal *ecal, gboolean only_if_exists)
 	switch (priv->load_state) {
 	case E_CAL_LOAD_AUTHENTICATING :
 	case E_CAL_LOAD_LOADING :
-		#ifndef E_CAL_DISABLE_DEPRECATED
-		g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED], 0, E_CALENDAR_STATUS_BUSY);
-		#endif
-
-		error = g_error_new_literal (E_CALENDAR_ERROR, E_CALENDAR_STATUS_BUSY, e_cal_get_error_message (E_CALENDAR_STATUS_BUSY));
-		g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED_EX], 0, error);
-		g_error_free (error);
+		async_report_idle (ecal, g_error_new_literal (E_CALENDAR_ERROR, E_CALENDAR_STATUS_BUSY, e_cal_get_error_message (E_CALENDAR_STATUS_BUSY)));
 		return;
 	case E_CAL_LOAD_LOADED :
-		#ifndef E_CAL_DISABLE_DEPRECATED
-		g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED], 0, E_CALENDAR_STATUS_OK);
-		#endif
-
-		g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED_EX], 0, NULL);
+		async_report_idle (ecal, NULL /* success */);
 		return;
 	default:
 		/* ignore everything else */
@@ -1438,14 +1443,9 @@ e_cal_open_async (ECal *ecal, gboolean only_if_exists)
 		&status,
 		#endif
 		FALSE, TRUE);
-	if (error) {
-		struct idle_async_error_reply_data *data;
 
-		data = g_new0 (struct idle_async_error_reply_data, 1);
-		data->ecal = g_object_ref (ecal);
-		data->error = error;
-		g_idle_add (idle_async_error_reply_cb, data);
-	}
+	if (error)
+		async_report_idle (ecal, error);
 }
 
 /**



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