[evolution] Bug #659125 - Reference counting issues in calendar



commit 6ea72f4fe7cd9ed44660589bf13eb153007cb62e
Author: Milan Crha <mcrha redhat com>
Date:   Thu Sep 15 14:54:31 2011 +0200

    Bug #659125 - Reference counting issues in calendar

 calendar/gui/dialogs/comp-editor.c           |    2 ++
 calendar/gui/e-cal-model.c                   |   23 ++++++++++++++++++-----
 modules/calendar/e-cal-shell-view-memopad.c  |    1 -
 modules/calendar/e-cal-shell-view-taskpad.c  |    3 +--
 modules/calendar/e-memo-shell-backend.c      |    3 +++
 modules/calendar/e-memo-shell-view-actions.c |    1 -
 modules/calendar/e-task-shell-backend.c      |    3 +++
 modules/calendar/e-task-shell-view-actions.c |    1 -
 modules/calendar/e-task-shell-view-private.c |    2 +-
 9 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 1d5a45a..5b3b520 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -1586,6 +1586,8 @@ comp_editor_dispose (GObject *object)
 		g_signal_handlers_disconnect_matched (
 			G_OBJECT (store), G_SIGNAL_MATCH_DATA,
 			0, 0, NULL, NULL, object);
+		g_object_unref (priv->attachment_view);
+		priv->attachment_view = NULL;
 	}
 
 	/* We want to destroy the pages after the widgets get destroyed,
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 0c8c59b..b7b56eb 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -2149,6 +2149,20 @@ typedef struct {
 	icalcomponent *icalcomp;
 } RecurrenceExpansionData;
 
+static void
+free_rdata (gpointer data)
+{
+	RecurrenceExpansionData *rdata = data;
+
+	if (!rdata)
+		return;
+
+	g_object_unref (rdata->client);
+	g_object_unref (rdata->view);
+	g_object_unref (rdata->model);
+	g_free (rdata);
+}
+
 static gboolean
 add_instance_cb (ECalComponent *comp,
                  time_t instance_start,
@@ -2308,13 +2322,12 @@ process_added (ECalClientView *view,
 
 			if (client_data) {
 				RecurrenceExpansionData *rdata = g_new0 (RecurrenceExpansionData, 1);
-				rdata->client = client;
-				rdata->view = view;
-				rdata->model = model;
-				rdata->icalcomp = l->data;
+				rdata->client = g_object_ref (client);
+				rdata->view = g_object_ref (view);
+				rdata->model = g_object_ref (model);
 
 				e_cal_client_generate_instances_for_object (rdata->client, l->data, priv->start, priv->end, client_data->cancellable,
-									    (ECalRecurInstanceFn) add_instance_cb, rdata, g_free);
+									    (ECalRecurInstanceFn) add_instance_cb, rdata, free_rdata);
 			}
 		} else {
 			e_table_model_pre_change (E_TABLE_MODEL (model));
diff --git a/modules/calendar/e-cal-shell-view-memopad.c b/modules/calendar/e-cal-shell-view-memopad.c
index bd1e9d5..4978ca2 100644
--- a/modules/calendar/e-cal-shell-view-memopad.c
+++ b/modules/calendar/e-cal-shell-view-memopad.c
@@ -92,7 +92,6 @@ action_calendar_memopad_new_cb (GtkAction *action,
 	gtk_window_present (GTK_WINDOW (editor));
 
 	g_object_unref (comp);
-	g_object_unref (client);
 }
 
 static void
diff --git a/modules/calendar/e-cal-shell-view-taskpad.c b/modules/calendar/e-cal-shell-view-taskpad.c
index 48c81ac..92263c7 100644
--- a/modules/calendar/e-cal-shell-view-taskpad.c
+++ b/modules/calendar/e-cal-shell-view-taskpad.c
@@ -160,7 +160,6 @@ action_calendar_taskpad_new_cb (GtkAction *action,
 	gtk_window_present (GTK_WINDOW (editor));
 
 	g_object_unref (comp);
-	g_object_unref (client);
 }
 
 static void
@@ -548,7 +547,7 @@ e_cal_shell_view_taskpad_open_task (ECalShellView *cal_shell_view,
 	editor = task_editor_new (comp_data->client, shell, flags);
 	comp_editor_edit_comp (editor, comp);
 
-	g_object_ref (comp);
+	g_object_unref (comp);
 
 	if (flags & COMP_EDITOR_IS_ASSIGNED)
 		task_editor_show_assignment (TASK_EDITOR (editor));
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index 6f80700..7edb82d 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -422,6 +422,8 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 		g_warning (
 			"%s: Failed to create/open client: %s",
 			G_STRFUNC, error->message);
+		if (client != NULL)
+			g_object_unref (client);
 		g_object_unref (source_list);
 		g_error_free (error);
 		goto exit;
@@ -443,6 +445,7 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 			"%s: Failed to get object: %s",
 			G_STRFUNC, error->message);
 		g_object_unref (source_list);
+		g_object_unref (client);
 		g_error_free (error);
 		goto exit;
 	}
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index eacb5c1..d71b893 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -385,7 +385,6 @@ action_memo_new_cb (GtkAction *action,
 	gtk_window_present (GTK_WINDOW (editor));
 
 	g_object_unref (comp);
-	g_object_unref (client);
 }
 
 static void
diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c
index bb296fd..f6a5e14 100644
--- a/modules/calendar/e-task-shell-backend.c
+++ b/modules/calendar/e-task-shell-backend.c
@@ -422,6 +422,8 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 		g_warning (
 			"%s: Failed to create/open client: %s",
 			G_STRFUNC, error->message);
+		if (client)
+			g_object_unref (client);
 		g_object_unref (source_list);
 		g_error_free (error);
 		goto exit;
@@ -443,6 +445,7 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 			"%s: Failed to get object: %s",
 			G_STRFUNC, error->message);
 		g_object_unref (source_list);
+		g_object_unref (client);
 		g_error_free (error);
 		goto exit;
 	}
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 1fb4867..2fe2849 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -453,7 +453,6 @@ action_task_new_cb (GtkAction *action,
 	gtk_window_present (GTK_WINDOW (editor));
 
 	g_object_unref (comp);
-	g_object_unref (client);
 }
 
 static void
diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c
index b812278..8c02cec 100644
--- a/modules/calendar/e-task-shell-view-private.c
+++ b/modules/calendar/e-task-shell-view-private.c
@@ -445,7 +445,7 @@ e_task_shell_view_open_task (ETaskShellView *task_shell_view,
 	editor = task_editor_new (comp_data->client, shell, flags);
 	comp_editor_edit_comp (editor, comp);
 
-	g_object_ref (comp);
+	g_object_unref (comp);
 
 	if (flags & COMP_EDITOR_IS_ASSIGNED)
 		task_editor_show_assignment (TASK_EDITOR (editor));



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