[gnome-calendar] week-header: use g_date_time_add_days for dnd date calculation
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] week-header: use g_date_time_add_days for dnd date calculation
- Date: Tue, 9 May 2017 20:03:04 +0000 (UTC)
commit a54e91a9b35a9daf7d7f0b52a37622f1cf472406
Author: Orkun Tezer <orkuntezerm gmail com>
Date: Sat May 6 00:07:57 2017 +0300
week-header: use g_date_time_add_days for dnd date calculation
Dnd at week header crashes with segmentation fault
The problem, calculation of dnd_date returns NULL when week_start is
in previous month.
Fix that by using g_date_time_add_days() function
https://bugzilla.gnome.org/show_bug.cgi?id=781955
src/views/gcal-week-header.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/views/gcal-week-header.c b/src/views/gcal-week-header.c
index 1736268..460450c 100644
--- a/src/views/gcal-week-header.c
+++ b/src/views/gcal-week-header.c
@@ -1353,6 +1353,7 @@ gcal_week_header_drag_drop (GtkWidget *widget,
g_autoptr (GDateTime) week_start;
g_autoptr (GDateTime) dnd_date;
g_autoptr (GDateTime) new_end;
+ g_autoptr (GDateTime) tmp_dt;
GDateTime *start_date;
GDateTime *end_date;
GTimeSpan difference;
@@ -1372,6 +1373,7 @@ gcal_week_header_drag_drop (GtkWidget *widget,
week_start = NULL;
dnd_date = NULL;
new_end = NULL;
+ tmp_dt = NULL;
if (!GCAL_IS_EVENT_WIDGET (event_widget))
return FALSE;
@@ -1393,21 +1395,22 @@ gcal_week_header_drag_drop (GtkWidget *widget,
* The only case where we don't touch the timezone is for
* timed, multiday events.
*/
- dnd_date = g_date_time_new (gcal_event_get_timezone (event),
- g_date_time_get_year (week_start),
- g_date_time_get_month (week_start),
- g_date_time_get_day_of_month (week_start) + drop_cell,
- g_date_time_get_hour (start_date),
- g_date_time_get_minute (start_date),
- 0);
+ tmp_dt = g_date_time_new (gcal_event_get_timezone (event),
+ g_date_time_get_year (week_start),
+ g_date_time_get_month (week_start),
+ g_date_time_get_day_of_month (week_start),
+ g_date_time_get_hour (start_date),
+ g_date_time_get_minute (start_date),
+ 0);
}
else
{
- dnd_date = g_date_time_new_utc (g_date_time_get_year (week_start),
- g_date_time_get_month (week_start),
- g_date_time_get_day_of_month (week_start) + drop_cell,
- 0, 0, 0);
+ tmp_dt = g_date_time_new_utc (g_date_time_get_year (week_start),
+ g_date_time_get_month (week_start),
+ g_date_time_get_day_of_month (week_start),
+ 0, 0, 0);
}
+ dnd_date = g_date_time_add_days (tmp_dt, drop_cell);
/* End date */
difference = turn_all_day ? 24 : g_date_time_difference (end_date, start_date) / G_TIME_SPAN_HOUR;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]