diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-04-13 03:55:28 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-04-13 06:35:12 +0800 |
commit | 08d5bdcf8b8bef913c9ad175927d528ff432332f (patch) | |
tree | 4162aea0f9d0d2837011ddb941263f2556f12947 | |
parent | 1df4952769b3211b90aecb3a359d8ae484fd1363 (diff) | |
download | gsoc2013-evolution-08d5bdcf8b8bef913c9ad175927d528ff432332f.tar.gz gsoc2013-evolution-08d5bdcf8b8bef913c9ad175927d528ff432332f.tar.zst gsoc2013-evolution-08d5bdcf8b8bef913c9ad175927d528ff432332f.zip |
Add e_cal_model_ref_default_client().
Replaces e_cal_model_get_default_client(), which was not thread-safe.
-rw-r--r-- | calendar/gui/dialogs/goto-dialog.c | 7 | ||||
-rw-r--r-- | calendar/gui/e-cal-model.c | 32 | ||||
-rw-r--r-- | calendar/gui/e-cal-model.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 12 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 42 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.c | 4 | ||||
-rw-r--r-- | calendar/gui/e-task-table.c | 4 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 39 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-view-actions.c | 6 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-view-private.c | 4 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-view-actions.c | 6 | ||||
-rw-r--r-- | 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 64c40ff285..7919666d7c 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 62c9188077..0aff1ce929 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -545,9 +545,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; @@ -1736,18 +1736,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; } @@ -1797,11 +1799,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; } @@ -2559,7 +2559,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; @@ -2568,11 +2568,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); } @@ -3788,8 +3788,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) { @@ -3810,6 +3810,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 f42ddd2937..4e189ab186 100644 --- a/calendar/gui/e-cal-model.h +++ b/calendar/gui/e-cal-model.h @@ -250,7 +250,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 cf01231502..8228e68285 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 4f0ca4e2bd..541b62ac20 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -613,7 +613,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; @@ -621,19 +621,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); @@ -684,14 +685,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 @@ -4993,7 +4998,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)); } @@ -8309,7 +8314,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; @@ -8332,7 +8336,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) { @@ -8344,6 +8347,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; @@ -8483,6 +8487,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; @@ -8510,6 +8516,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; @@ -8541,6 +8549,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; } @@ -8571,7 +8581,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; @@ -8591,8 +8600,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); @@ -8609,6 +8616,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; @@ -8721,6 +8729,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; @@ -8748,6 +8758,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; @@ -8779,6 +8791,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 ea8f645acc..f229bcf7a2 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 6f7fb83317..0ec834ff6b 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 7af4d8590c..8d1e8815de 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -566,7 +566,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; @@ -576,17 +576,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 (); @@ -625,18 +627,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); @@ -645,17 +646,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 @@ -3017,7 +3020,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 5e30e24fcf..f0c16bb99a 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 50b9e5f8aa..a84a44134d 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 0c3ab2e040..5102def69b 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 bc538c6e75..a3e29c9ad3 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 |