week-grid: make sure events span at least 1 minute

When adding an event with the same start and end dates and
times, the event effectively spans 0 minutes, leading a division
by zero and causing varius UI glitches.

Fix that by making sure events span at least 1 minute.

https://bugzilla.gnome.org/show_bug.cgi?id=777414
This commit is contained in:
Georges Basile Stavracas Neto
2017-02-01 15:06:56 -02:00
parent e119d27718
commit cdc5bde96a
+8
View File
@@ -166,6 +166,14 @@ get_event_range (GcalWeekGrid *self,
diff = g_date_time_difference (event_end, week_start);
*end = CLAMP (diff / G_TIME_SPAN_MINUTE, 0, MAX_MINUTES);
/*
* XXX: it may happen that the event has the same start and end
* dates. For this case, just enforce that the event is at least
* 1 minute long.
*/
if (start && *start == *end)
*end = *end + 1;
g_clear_pointer (&event_end, g_date_time_unref);
}