week-header: don't attempt to add events incorrectly

One of the biggest issues of GNOME Calendar views right now
is that they rely on GObject property system to update the
active date. Even gcal_view_set_date() is just a wrapper
around GObject set.

Because GObject asynchronously updates the property by letting
the mainloop handle it, we can never be assured that all the
views had their views updated before updating the data model.

This patch temporarily adds sanity checks to GcalWeekHeader
to prevent making Calendar unusable, until we fix GcalView.
This commit is contained in:
Georges Basile Stavracas Neto
2017-03-24 22:21:24 -03:00
parent 26ecf3c161
commit c2f3953dde
+10 -2
View File
@@ -367,9 +367,10 @@ update_overflow (GcalWeekHeader *self)
gtk_label_set_label (GTK_LABEL (label), text);
g_free (text);
}
else
else if (label)
{
g_clear_pointer (&self->overflow_label[i], gtk_widget_destroy);
gtk_widget_destroy (label);
self->overflow_label[i] = NULL;
}
}
@@ -1668,6 +1669,13 @@ gcal_week_header_add_event (GcalWeekHeader *self,
else
end = 6;
/* Sanity checks */
if (start > end || start > 6 || end < 0)
{
g_warning ("Error adding event '%s' to the week header", gcal_event_get_summary (event));
return;
}
/* Add the event widget to the grid */
add_event_to_grid (self, event, start, end);