[evolution/wip/gsettings] Bug #653154 - Crash when constructing calendar view



commit f286e88fae02a7da640ab1637130b00d3c366c08
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jun 27 11:31:32 2011 +0200

    Bug #653154 - Crash when constructing calendar view

 calendar/gui/e-cal-model.c              |   31 ++++++++++++++++++++++++-------
 calendar/gui/e-week-view.c              |    2 ++
 modules/calendar/e-cal-shell-sidebar.c  |   25 ++++++++++++++++++++-----
 modules/calendar/e-memo-shell-sidebar.c |   25 ++++++++++++++++++++-----
 modules/calendar/e-task-shell-sidebar.c |   25 ++++++++++++++++++++-----
 5 files changed, 86 insertions(+), 22 deletions(-)
---
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 5e0c9cc..9778d3e 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -2561,11 +2561,32 @@ backend_died_cb (ECalClient *client, gpointer user_data)
 }
 
 static void
+cal_model_retrieve_capabilies_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+	ECalClient *client = E_CAL_CLIENT (source_object);
+	ECalModel *model = user_data;
+	ECalModelClient *client_data;
+	gchar *capabilities = NULL;
+
+	g_return_if_fail (client != NULL);
+	g_return_if_fail (model != NULL);
+
+	e_client_retrieve_capabilities_finish (E_CLIENT (client), result, &capabilities, NULL);
+	g_free (capabilities);
+
+	e_cal_model_update_status_message (model, NULL, -1.0);
+
+	client_data = find_client_data (model, client);
+	g_return_if_fail (client_data);
+
+	update_e_cal_view_for_client (model, client_data);
+}
+
+static void
 client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
 {
 	ECalClient *client = E_CAL_CLIENT (source_object);
 	ECalModel *model = (ECalModel *) user_data;
-	ECalModelClient *client_data;
 	GError *error = NULL;
 
 	e_client_open_finish (E_CLIENT (client), result, &error);
@@ -2578,12 +2599,8 @@ client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_da
 		return;
 	}
 
-	e_cal_model_update_status_message (model, NULL, -1.0);
-
-	client_data = find_client_data (model, client);
-	g_return_if_fail (client_data);
-
-	update_e_cal_view_for_client (model, client_data);
+	/* to have them ready for later use */
+	e_client_retrieve_capabilities (E_CLIENT (client), NULL, cal_model_retrieve_capabilies_cb, model);
 }
 
 static ECalModelClient *
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 47f03a9..2385b9f 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -3244,6 +3244,7 @@ e_week_view_reshape_event_span (EWeekView *week_view,
 				- E_WEEK_VIEW_EVENT_BORDER_WIDTH
 				- E_WEEK_VIEW_EVENT_EDGE_X_PAD - text_x;
 		} else {
+			text = NULL;
 			/* Get the width of the text of the event. This is a
 			   bit of a hack. It would be better if EText could
 			   tell us this. */
@@ -3951,6 +3952,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
 	if (!uid)
 		return;
 
+	text = NULL;
 	g_object_set (span->text_item, "handle_popup", FALSE, NULL);
 	g_object_get (G_OBJECT (span->text_item), "text", &text, NULL);
 
diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c
index 8e3010d..e33a7dc 100644
--- a/modules/calendar/e-cal-shell-sidebar.c
+++ b/modules/calendar/e-cal-shell-sidebar.c
@@ -164,6 +164,24 @@ cal_shell_sidebar_backend_error_cb (ECalShellSidebar *cal_shell_sidebar,
 }
 
 static void
+cal_shell_sidebar_retrieve_capabilies_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+	ECalClient *client = E_CAL_CLIENT (source_object);
+	ECalShellSidebar *cal_shell_sidebar = user_data;
+	gchar *capabilities = NULL;
+
+	g_return_if_fail (client != NULL);
+	g_return_if_fail (cal_shell_sidebar != NULL);
+
+	e_client_retrieve_capabilities_finish (E_CLIENT (client), result, &capabilities, NULL);
+	g_free (capabilities);
+
+	cal_shell_sidebar_emit_status_message (cal_shell_sidebar, _("Loading calendars"));
+	cal_shell_sidebar_emit_client_added (cal_shell_sidebar, client);
+	cal_shell_sidebar_emit_status_message (cal_shell_sidebar, NULL);
+}
+
+static void
 cal_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
 {
 	ECalClient *client = E_CAL_CLIENT (source_object);
@@ -171,7 +189,6 @@ cal_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result
 	EShellView *shell_view;
 	EShellContent *shell_content;
 	EShellSidebar *shell_sidebar;
-	const gchar *message;
 	GError *error = NULL;
 
 	shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar);
@@ -224,10 +241,8 @@ cal_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result
 
 	g_clear_error (&error);
 
-	message = _("Loading calendars");
-	cal_shell_sidebar_emit_status_message (cal_shell_sidebar, message);
-	cal_shell_sidebar_emit_client_added (cal_shell_sidebar, client);
-	cal_shell_sidebar_emit_status_message (cal_shell_sidebar, NULL);
+	/* to have them ready for later use */
+	e_client_retrieve_capabilities (E_CLIENT (client), NULL, cal_shell_sidebar_retrieve_capabilies_cb, cal_shell_sidebar);
 }
 
 static void
diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c
index 5a28611..213179c 100644
--- a/modules/calendar/e-memo-shell-sidebar.c
+++ b/modules/calendar/e-memo-shell-sidebar.c
@@ -159,6 +159,24 @@ memo_shell_sidebar_backend_error_cb (EMemoShellSidebar *memo_shell_sidebar,
 }
 
 static void
+memo_shell_sidebar_retrieve_capabilies_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+	ECalClient *client = E_CAL_CLIENT (source_object);
+	EMemoShellSidebar *memo_shell_sidebar = user_data;
+	gchar *capabilities = NULL;
+
+	g_return_if_fail (client != NULL);
+	g_return_if_fail (memo_shell_sidebar != NULL);
+
+	e_client_retrieve_capabilities_finish (E_CLIENT (client), result, &capabilities, NULL);
+	g_free (capabilities);
+
+	memo_shell_sidebar_emit_status_message (memo_shell_sidebar, _("Loading memos"));
+	memo_shell_sidebar_emit_client_added (memo_shell_sidebar, client);
+	memo_shell_sidebar_emit_status_message (memo_shell_sidebar, NULL);
+}
+
+static void
 memo_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
 {
 	ECalClient *client = E_CAL_CLIENT (source_object);
@@ -166,7 +184,6 @@ memo_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *resul
 	EShellView *shell_view;
 	EShellContent *shell_content;
 	EShellSidebar *shell_sidebar;
-	const gchar *message;
 	GError *error = NULL;
 
 	shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar);
@@ -219,10 +236,8 @@ memo_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *resul
 
 	g_clear_error (&error);
 
-	message = _("Loading memos");
-	memo_shell_sidebar_emit_status_message (memo_shell_sidebar, message);
-	memo_shell_sidebar_emit_client_added (memo_shell_sidebar, client);
-	memo_shell_sidebar_emit_status_message (memo_shell_sidebar, NULL);
+	/* to have them ready for later use */
+	e_client_retrieve_capabilities (E_CLIENT (client), NULL, memo_shell_sidebar_retrieve_capabilies_cb, memo_shell_sidebar);
 }
 
 static void
diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c
index b37ab6d..04d2c25 100644
--- a/modules/calendar/e-task-shell-sidebar.c
+++ b/modules/calendar/e-task-shell-sidebar.c
@@ -159,6 +159,24 @@ task_shell_sidebar_backend_error_cb (ETaskShellSidebar *task_shell_sidebar,
 }
 
 static void
+task_shell_sidebar_retrieve_capabilies_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+	ECalClient *client = E_CAL_CLIENT (source_object);
+	ETaskShellSidebar *task_shell_sidebar = user_data;
+	gchar *capabilities = NULL;
+
+	g_return_if_fail (client != NULL);
+	g_return_if_fail (task_shell_sidebar != NULL);
+
+	e_client_retrieve_capabilities_finish (E_CLIENT (client), result, &capabilities, NULL);
+	g_free (capabilities);
+
+	task_shell_sidebar_emit_status_message (task_shell_sidebar, _("Loading tasks"));
+	task_shell_sidebar_emit_client_added (task_shell_sidebar, client);
+	task_shell_sidebar_emit_status_message (task_shell_sidebar, NULL);
+}
+
+static void
 task_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
 {
 	ECalClient *client = E_CAL_CLIENT (source_object);
@@ -166,7 +184,6 @@ task_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *resul
 	EShellView *shell_view;
 	EShellContent *shell_content;
 	EShellSidebar *shell_sidebar;
-	const gchar *message;
 	GError *error = NULL;
 
 	shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar);
@@ -219,10 +236,8 @@ task_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *resul
 
 	g_clear_error (&error);
 
-	message = _("Loading tasks");
-	task_shell_sidebar_emit_status_message (task_shell_sidebar, message);
-	task_shell_sidebar_emit_client_added (task_shell_sidebar, client);
-	task_shell_sidebar_emit_status_message (task_shell_sidebar, NULL);
+	/* to have them ready for later use */
+	e_client_retrieve_capabilities (E_CLIENT (client), NULL, task_shell_sidebar_retrieve_capabilies_cb, task_shell_sidebar);
 }
 
 static void



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