events: fix handling of event with no end date

Fix the sigsegv in edit-dialog and event-widgets when there's no
end-date set.
Set a guard in Utils::gcal_dup_icaltime function.
There's still some problems with the events showing the first time but
not anymore.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=736002
This commit is contained in:
Erick Pérez Castellanos
2014-12-08 11:21:14 -05:00
parent e3976bdb80
commit e62f48bfea
3 changed files with 41 additions and 34 deletions
+22 -22
View File
@@ -861,40 +861,40 @@ gcal_edit_dialog_set_event_data (GcalEditDialog *dialog,
dtstart.value->month,
dtstart.value->year);
/* end date */
e_cal_component_get_dtend (priv->component, &dtend);
gcal_date_entry_set_date (GCAL_DATE_ENTRY (priv->end_date_entry),
dtend.value->day,
dtend.value->month,
dtend.value->year);
/* all_day */
all_day = (dtstart.value->is_date == 1 && dtend.value->is_date == 1);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->all_day_check), all_day);
/* start time */
if (all_day)
{
dtstart.value->hour = 0;
dtstart.value->minute = 0;
}
gcal_time_entry_set_time (GCAL_TIME_ENTRY (priv->start_time_entry),
dtstart.value->hour,
dtstart.value->minute);
/* end time */
if (all_day)
gcal_time_entry_set_time (GCAL_TIME_ENTRY (priv->start_time_entry), dtstart.value->hour, dtstart.value->minute);
/* end date */
e_cal_component_get_dtend (priv->component, &dtend);
if (dtend.value != NULL)
{
dtend.value->hour = 0;
dtend.value->minute = 0;
gcal_date_entry_set_date (GCAL_DATE_ENTRY (priv->end_date_entry),
dtend.value->day, dtend.value->month, dtend.value->year);
all_day = (dtstart.value->is_date == 1 && dtend.value->is_date == 1);
if (!all_day)
gcal_time_entry_set_time (GCAL_TIME_ENTRY (priv->end_time_entry), dtend.value->hour, dtend.value->minute);
}
else
{
gcal_date_entry_set_date (GCAL_DATE_ENTRY (priv->end_date_entry),
dtstart.value->day, dtstart.value->month, dtstart.value->year);
gcal_time_entry_set_time (GCAL_TIME_ENTRY (priv->end_time_entry), dtstart.value->hour, dtstart.value->minute);
all_day = FALSE;
}
gcal_time_entry_set_time (GCAL_TIME_ENTRY (priv->end_time_entry),
dtend.value->hour,
dtend.value->minute);
e_cal_component_free_datetime (&dtstart);
e_cal_component_free_datetime (&dtend);
/* all_day */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->all_day_check), all_day);
/* location */
e_cal_component_get_location (priv->component, &const_text);
gtk_entry_set_text (GTK_ENTRY (priv->location_entry),
+16 -12
View File
@@ -796,20 +796,23 @@ gcal_event_widget_new_from_data (GcalEventData *data)
/* end date */
e_cal_component_get_dtend (priv->component, &dt);
date = gcal_dup_icaltime (dt.value);
if (dt.value != NULL)
{
date = gcal_dup_icaltime (dt.value);
/* FIXME: fix the timezone issue */
/* if (date->is_date != 1) */
/* *date = icaltime_convert_to_zone (*(dt.value), */
/* priv->system_timezone); */
end_is_date = date->is_date == 1;
/* FIXME: fix the timezone issue */
/* if (date->is_date != 1) */
/* *date = icaltime_convert_to_zone (*(dt.value), */
/* priv->system_timezone); */
end_is_date = date->is_date == 1;
gcal_event_widget_set_end_date (event, date);
e_cal_component_free_datetime (&dt);
g_free (date);
gcal_event_widget_set_end_date (event, date);
e_cal_component_free_datetime (&dt);
g_free (date);
/* set_all_day */
gcal_event_widget_set_all_day (event, start_is_date && end_is_date);
/* set_all_day */
gcal_event_widget_set_all_day (event, start_is_date && end_is_date);
}
/* set_has_reminders */
gcal_event_widget_set_has_reminders (
@@ -900,7 +903,8 @@ gcal_event_widget_set_end_date (GcalEventWidget *event,
* gcal_event_widget_get_end_date:
* @event: a #GcalEventWidget
*
* Return the end date of the event
* Return the end date of the event. If the event has no end_date
* (as Google does on 0 sec events) %NULL will be returned
*
* Returns: (transfer full): Release with g_free()
**/
+3
View File
@@ -128,6 +128,9 @@ gcal_dup_icaltime (const icaltimetype *date)
{
icaltimetype *new_date;
if (date == NULL)
return NULL;
new_date= g_new (icaltimetype, 1);
new_date->year = date->year;
new_date->month = date->month;