[evolution/gnome-3-8] Add e_cal_model_ref_default_client().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-8] Add e_cal_model_ref_default_client().
- Date: Fri, 12 Apr 2013 23:59:26 +0000 (UTC)
commit 3385b67062502277411bad84e576a19c633918c1
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Apr 12 15:55:28 2013 -0400
Add e_cal_model_ref_default_client().
Replaces e_cal_model_get_default_client(), which was not thread-safe.
(cherry picked from commit 08d5bdcf8b8bef913c9ad175927d528ff432332f)
calendar/gui/dialogs/goto-dialog.c | 7 +++-
calendar/gui/e-cal-model.c | 32 ++++++++++---------
calendar/gui/e-cal-model.h | 2 +-
calendar/gui/e-calendar-view.c | 12 +++++--
calendar/gui/e-day-view.c | 42 +++++++++++++++++--------
calendar/gui/e-memo-table.c | 4 ++-
calendar/gui/e-task-table.c | 4 ++-
calendar/gui/e-week-view.c | 39 +++++++++++++-----------
modules/calendar/e-memo-shell-view-actions.c | 6 ++-
modules/calendar/e-memo-shell-view-private.c | 4 ++-
modules/calendar/e-task-shell-view-actions.c | 6 ++-
modules/calendar/e-task-shell-view-private.c | 4 ++-
12 files changed, 100 insertions(+), 62 deletions(-)
---
diff --git a/calendar/gui/dialogs/goto-dialog.c b/calendar/gui/dialogs/goto-dialog.c
index 64c40ff..7919666 100644
--- a/calendar/gui/dialogs/goto-dialog.c
+++ b/calendar/gui/dialogs/goto-dialog.c
@@ -96,9 +96,12 @@ ecal_date_range_changed (ECalendarItem *calitem,
ECalClient *client;
model = gnome_calendar_get_model (dlg->gcal);
- client = e_cal_model_get_default_client (model);
- if (client)
+ client = e_cal_model_ref_default_client (model);
+
+ if (client != NULL) {
tag_calendar_by_client (dlg->ecal, client, dlg->cancellable);
+ g_object_unref (client);
+ }
}
/* Event handler for day groups in the month item. A button press makes
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 8c41055..2f8d444 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -485,9 +485,9 @@ cal_model_get_property (GObject *object,
return;
case PROP_DEFAULT_CLIENT:
- g_value_set_object (
+ g_value_take_object (
value,
- e_cal_model_get_default_client (
+ e_cal_model_ref_default_client (
E_CAL_MODEL (object)));
return;
@@ -1543,18 +1543,20 @@ e_cal_model_test_row_editable (ECalModel *model,
comp_data = e_cal_model_get_component_at (model, row);
- if (comp_data)
- client = comp_data->client;
+ if (comp_data != NULL && comp_data->client != NULL)
+ client = g_object_ref (comp_data->client);
} else {
- client = e_cal_model_get_default_client (model);
+ client = e_cal_model_ref_default_client (model);
}
- readonly = client == NULL;
+ readonly = (client == NULL);
if (!readonly)
readonly = e_client_is_readonly (E_CLIENT (client));
+ g_clear_object (&client);
+
return !readonly;
}
@@ -1604,11 +1606,9 @@ ecm_append_row (ETableModel *etm,
comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL);
- comp_data->client = e_cal_model_get_default_client (model);
- if (comp_data->client)
- g_object_ref (comp_data->client);
+ comp_data->client = e_cal_model_ref_default_client (model);
- if (!comp_data->client) {
+ if (comp_data->client == NULL) {
g_object_unref (comp_data);
return;
}
@@ -2257,7 +2257,7 @@ e_cal_model_set_work_day_start_minute (ECalModel *model,
}
ECalClient *
-e_cal_model_get_default_client (ECalModel *model)
+e_cal_model_ref_default_client (ECalModel *model)
{
ClientData *client_data;
ECalClient *default_client = NULL;
@@ -2266,11 +2266,11 @@ e_cal_model_get_default_client (ECalModel *model)
g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
if (model->priv->default_client != NULL)
- return model->priv->default_client;
+ return g_object_ref (model->priv->default_client);
client_data = cal_model_clients_peek (model);
if (client_data != NULL) {
- default_client = client_data->client;
+ default_client = g_object_ref (client_data->client);
client_data_unref (client_data);
}
@@ -3486,8 +3486,8 @@ e_cal_model_create_component_with_defaults (ECalModel *model,
priv = model->priv;
- client = e_cal_model_get_default_client (model);
- if (!client)
+ client = e_cal_model_ref_default_client (model);
+ if (client == NULL)
return icalcomponent_new (priv->kind);
switch (priv->kind) {
@@ -3508,6 +3508,8 @@ e_cal_model_create_component_with_defaults (ECalModel *model,
return NULL;
}
+ g_object_unref (client);
+
if (!comp)
return icalcomponent_new (priv->kind);
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index d3a4fcc..0a30ff6 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -243,7 +243,7 @@ gint e_cal_model_get_work_day_start_minute
void e_cal_model_set_work_day_start_minute
(ECalModel *model,
gint work_day_start_minute);
-ECalClient * e_cal_model_get_default_client (ECalModel *model);
+ECalClient * e_cal_model_ref_default_client (ECalModel *model);
void e_cal_model_set_default_client (ECalModel *model,
ECalClient *client);
GList * e_cal_model_list_clients (ECalModel *model);
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index cf01231..8228e68 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -622,15 +622,15 @@ clipboard_get_calendar_data (ECalendarView *cal_view,
if (!icalcomp)
return FALSE;
- default_zone = e_cal_model_get_timezone (cal_view->priv->model);
- client = e_cal_model_get_default_client (cal_view->priv->model);
-
/* check the type of the component */
/* FIXME An error dialog if we return? */
kind = icalcomponent_isa (icalcomp);
if (kind != ICAL_VCALENDAR_COMPONENT && kind != ICAL_VEVENT_COMPONENT)
return FALSE;
+ default_zone = e_cal_model_get_timezone (cal_view->priv->model);
+ client = e_cal_model_ref_default_client (cal_view->priv->model);
+
#if 0 /* KILL-BONOBO */
e_calendar_view_set_status_message (cal_view, _("Updating objects"), -1);
#endif
@@ -688,6 +688,8 @@ clipboard_get_calendar_data (ECalendarView *cal_view,
*copied_list = g_slist_prepend (*copied_list, g_strdup (icalcomponent_get_uid
(icalcomp)));
}
+ g_object_unref (client);
+
return ret;
#if 0 /* KILL-BONOBO */
@@ -1517,7 +1519,7 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view,
priv = cal_view->priv;
- default_client = e_cal_model_get_default_client (priv->model);
+ default_client = e_cal_model_ref_default_client (priv->model);
g_return_if_fail (default_client != NULL);
dt.value = &itt;
@@ -1571,6 +1573,8 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view,
cal_view, default_client, icalcomp, flags);
g_object_unref (comp);
+
+ g_object_unref (default_client);
}
/**
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 980c8ed..b9409a4 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -574,7 +574,7 @@ e_day_view_add_new_event_in_selected_range (EDayView *day_view,
icalcomponent *icalcomp;
ECalClient *client;
ECalModel *model;
- ECalComponent *comp;
+ ECalComponent *comp = NULL;
gint day, event_num;
time_t dtstart, dtend;
ECalComponentDateTime start_dt, end_dt;
@@ -582,19 +582,20 @@ e_day_view_add_new_event_in_selected_range (EDayView *day_view,
const gchar *uid;
AddEventData add_event_data;
ESourceRegistry *registry;
+ gboolean success = FALSE;
model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
registry = e_cal_model_get_registry (model);
- client = e_cal_model_get_default_client (model);
+ client = e_cal_model_ref_default_client (model);
/* Check if the client is read only */
if (e_client_is_readonly (E_CLIENT (client)))
- return FALSE;
+ goto exit;
icalcomp = e_cal_model_create_component_with_defaults (model, day_view->selection_in_top_canvas);
if (!icalcomp)
- return FALSE;
+ goto exit;
uid = icalcomponent_get_uid (icalcomp);
@@ -645,14 +646,18 @@ e_day_view_add_new_event_in_selected_range (EDayView *day_view,
if (!e_day_view_find_event_from_uid (day_view, client, uid, NULL, &day, &event_num)) {
g_warning ("Couldn't find event to start editing.\n");
- g_object_unref (comp);
- return FALSE;
+ goto exit;
}
e_day_view_start_editing_event (day_view, day, event_num, key_event);
- g_object_unref (comp);
- return TRUE;
+ success = TRUE;
+
+exit:
+ g_clear_object (&comp);
+ g_clear_object (&client);
+
+ return success;
}
static void
@@ -4925,7 +4930,7 @@ e_day_view_add_event (ESourceRegistry *registry,
} else {
event.comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL);
- event.comp_data->client = g_object_ref (e_cal_model_get_default_client
(e_calendar_view_get_model (E_CALENDAR_VIEW (add_event_data->day_view))));
+ event.comp_data->client = e_cal_model_ref_default_client (e_calendar_view_get_model
(E_CALENDAR_VIEW (add_event_data->day_view)));
e_cal_component_abort_sequence (comp);
event.comp_data->icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent
(comp));
}
@@ -8214,7 +8219,6 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
struct icaltimetype itt;
time_t dt;
gboolean all_day_event;
- ECalClient *client;
ECalModel *model;
ECalendarView *cal_view;
gboolean drag_from_same_window;
@@ -8234,7 +8238,6 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
model = e_calendar_view_get_model (cal_view);
registry = e_cal_model_get_registry (model);
- client = e_cal_model_get_default_client (model);
/* Note that we only support DnD within the EDayView at present. */
if (length >= 0 && format == 8 && day_view->drag_event_day != -1) {
@@ -8246,6 +8249,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
NULL);
if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) {
CalObjModType mod = CALOBJ_MOD_ALL;
+ ECalClient *client;
GtkWindow *toplevel;
num_days = 1;
@@ -8385,6 +8389,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
}
if (length >= 0 && format == 8 && !drag_from_same_window) {
+ ECalClient *client;
+
/* We are dragging between different window */
icalcomponent *icalcomp;
@@ -8412,6 +8418,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
dtstart = day_view->day_starts[day];
+ client = e_cal_model_ref_default_client (model);
+
if (kind == ICAL_VCALENDAR_COMPONENT) {
icalcomponent_kind child_kind;
icalcomponent *subcomp;
@@ -8443,6 +8451,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
e_calendar_view_add_event (E_CALENDAR_VIEW (day_view), client, dtstart, default_zone,
icalcomp, TRUE);
}
+ g_object_unref (client);
+
gtk_drag_finish (context, TRUE, TRUE, time);
return;
}
@@ -8473,7 +8483,6 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
ESourceRegistry *registry;
struct icaltimetype itt;
time_t dt;
- ECalClient *client;
gboolean drag_from_same_window;
const guchar *data;
gint format, length;
@@ -8493,8 +8502,6 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
else
drag_from_same_window = FALSE;
- client = e_cal_model_get_default_client (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)));
-
gnome_canvas_get_scroll_offsets (
GNOME_CANVAS (widget),
&scroll_x, &scroll_y);
@@ -8511,6 +8518,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
&row, NULL);
if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) {
CalObjModType mod = CALOBJ_MOD_ALL;
+ ECalClient *client;
GtkWindow *toplevel;
num_rows = 1;
@@ -8623,6 +8631,8 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
}
if (length >= 0 && format == 8 && !drag_from_same_window) {
+ ECalClient *client;
+
/* We are dragging between different window */
icalcomponent *icalcomp;
@@ -8650,6 +8660,8 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
dtstart = e_day_view_convert_grid_position_to_time (day_view, day, row);
+ client = e_cal_model_ref_default_client (model);
+
if (kind == ICAL_VCALENDAR_COMPONENT) {
icalcomponent_kind child_kind;
icalcomponent *subcomp;
@@ -8681,6 +8693,8 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
e_calendar_view_add_event (E_CALENDAR_VIEW (day_view), client, dtstart, default_zone,
icalcomp, FALSE);
}
+ g_object_unref (client);
+
gtk_drag_finish (context, TRUE, TRUE, time);
return;
}
diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c
index ea8f645..f229bcf 100644
--- a/calendar/gui/e-memo-table.c
+++ b/calendar/gui/e-memo-table.c
@@ -858,7 +858,7 @@ clipboard_get_calendar_data (EMemoTable *memo_table,
}
model = e_memo_table_get_model (memo_table);
- client = e_cal_model_get_default_client (model);
+ client = e_cal_model_ref_default_client (model);
status_message = _("Updating objects");
memo_table_emit_status_message (memo_table, status_message, -1.0);
@@ -931,6 +931,8 @@ clipboard_get_calendar_data (EMemoTable *memo_table,
}
memo_table_emit_status_message (memo_table, NULL, -1.0);
+
+ g_object_unref (client);
}
static void
diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c
index 6f7fb83..0ec834f 100644
--- a/calendar/gui/e-task-table.c
+++ b/calendar/gui/e-task-table.c
@@ -1156,7 +1156,7 @@ clipboard_get_calendar_data (ETaskTable *task_table,
}
model = e_task_table_get_model (task_table);
- client = e_cal_model_get_default_client (model);
+ client = e_cal_model_ref_default_client (model);
status_message = _("Updating objects");
task_table_emit_status_message (task_table, status_message, -1.0);
@@ -1229,6 +1229,8 @@ clipboard_get_calendar_data (ETaskTable *task_table,
}
task_table_emit_status_message (task_table, NULL, -1.0);
+
+ g_object_unref (client);
}
static void
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 24bf1f1..971ba93 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -532,7 +532,7 @@ e_week_view_add_new_event_in_selected_range (EWeekView *week_view,
{
ECalClient *client;
ECalModel *model;
- ECalComponent *comp;
+ ECalComponent *comp = NULL;
icalcomponent *icalcomp;
gint event_num;
ECalComponentDateTime date;
@@ -542,17 +542,19 @@ e_week_view_add_new_event_in_selected_range (EWeekView *week_view,
AddEventData add_event_data;
EWeekViewEvent *wvevent;
EWeekViewEventSpan *span;
+ gboolean success = FALSE;
- /* Check if the client is read only */
model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
- client = e_cal_model_get_default_client (model);
+ client = e_cal_model_ref_default_client (model);
+
+ /* Check if the client is read only */
if (e_client_is_readonly (E_CLIENT (client)))
- return FALSE;
+ goto exit;
/* Add a new event covering the selected range. */
icalcomp = e_cal_model_create_component_with_defaults (e_calendar_view_get_model (E_CALENDAR_VIEW
(week_view)), TRUE);
if (!icalcomp)
- return FALSE;
+ goto exit;
uid = icalcomponent_get_uid (icalcomp);
comp = e_cal_component_new ();
@@ -591,18 +593,17 @@ e_week_view_add_new_event_in_selected_range (EWeekView *week_view,
if (!e_week_view_find_event_from_uid (week_view, client, uid, NULL, &event_num)) {
g_warning ("Couldn't find event to start editing.\n");
- g_object_unref (comp);
- return FALSE;
+ goto exit;
}
if (!is_array_index_in_bounds (week_view->events, event_num))
- return FALSE;
+ goto exit;
wvevent = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
if (!is_array_index_in_bounds (week_view->spans, wvevent->spans_index + 0))
- return FALSE;
+ goto exit;
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
wvevent->spans_index + 0);
@@ -611,17 +612,19 @@ e_week_view_add_new_event_in_selected_range (EWeekView *week_view,
if (!span->text_item) {
e_week_view_foreach_event_with_uid (week_view, uid,
e_week_view_remove_event_cb, NULL);
- g_object_unref (comp);
- return FALSE;
- } else {
- e_week_view_start_editing_event (
- week_view, event_num, 0,
- (gchar *) initial_text);
+ goto exit;
}
- g_object_unref (comp);
+ e_week_view_start_editing_event (
+ week_view, event_num, 0, (gchar *) initial_text);
- return TRUE;
+ success = TRUE;
+
+exit:
+ g_clear_object (&comp);
+ g_clear_object (&client);
+
+ return success;
}
static void
@@ -2961,7 +2964,7 @@ e_week_view_add_event (ECalComponent *comp,
} else {
event.comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL);
- event.comp_data->client = g_object_ref (e_cal_model_get_default_client
(e_calendar_view_get_model (E_CALENDAR_VIEW (add_event_data->week_view))));
+ event.comp_data->client = e_cal_model_ref_default_client (e_calendar_view_get_model
(E_CALENDAR_VIEW (add_event_data->week_view)));
e_cal_component_abort_sequence (comp);
event.comp_data->icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent
(comp));
}
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index 5e30e24..f0c16bb 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -387,12 +387,12 @@ action_memo_new_cb (GtkAction *action,
ECalModel *model;
model = e_memo_table_get_model (memo_table);
- client = e_cal_model_get_default_client (model);
+ client = e_cal_model_ref_default_client (model);
} else {
ECalModelComponent *comp_data;
comp_data = list->data;
- client = comp_data->client;
+ client = g_object_ref (comp_data->client);
g_slist_free (list);
}
@@ -406,6 +406,8 @@ 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-memo-shell-view-private.c b/modules/calendar/e-memo-shell-view-private.c
index 50b9e5f..a84a441 100644
--- a/modules/calendar/e-memo-shell-view-private.c
+++ b/modules/calendar/e-memo-shell-view-private.c
@@ -37,11 +37,13 @@ memo_shell_view_model_row_appended_cb (EMemoShellView *memo_shell_view,
/* This is the "Click to Add" handler. */
- client = e_cal_model_get_default_client (model);
+ client = e_cal_model_ref_default_client (model);
source = e_client_get_source (E_CLIENT (client));
memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
e_memo_shell_sidebar_add_source (memo_shell_sidebar, source);
+
+ g_object_unref (client);
}
static void
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 0c3ab2e..5102def 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -456,12 +456,12 @@ action_task_new_cb (GtkAction *action,
ECalModel *model;
model = e_task_table_get_model (task_table);
- client = e_cal_model_get_default_client (model);
+ client = e_cal_model_ref_default_client (model);
} else {
ECalModelComponent *comp_data;
comp_data = list->data;
- client = comp_data->client;
+ client = g_object_ref (comp_data->client);
g_slist_free (list);
}
@@ -474,6 +474,8 @@ 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 4da3fbd..56432d1 100644
--- a/modules/calendar/e-task-shell-view-private.c
+++ b/modules/calendar/e-task-shell-view-private.c
@@ -37,11 +37,13 @@ task_shell_view_model_row_appended_cb (ETaskShellView *task_shell_view,
/* This is the "Click to Add" handler. */
- client = e_cal_model_get_default_client (model);
+ client = e_cal_model_ref_default_client (model);
source = e_client_get_source (E_CLIENT (client));
task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
e_task_shell_sidebar_add_source (task_shell_sidebar, source);
+
+ g_object_unref (client);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]