mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
Avoid a crash in testcalendar
When changing between months, we can get into a situation like 'February 30", which GDate doesn't accept. Don't crash in that case.
This commit is contained in:
parent
31f502a9ae
commit
7b9065c2ee
@ -67,11 +67,17 @@ calendar_date_to_string (CalendarData *data,
|
|||||||
|
|
||||||
gtk_calendar_get_date (GTK_CALENDAR(data->window),
|
gtk_calendar_get_date (GTK_CALENDAR(data->window),
|
||||||
&year, &month, &day);
|
&year, &month, &day);
|
||||||
|
if (g_date_valid_dmy (day, month + 1, year))
|
||||||
|
{
|
||||||
date = g_date_new_dmy (day, month + 1, year);
|
date = g_date_new_dmy (day, month + 1, year);
|
||||||
g_date_strftime (buffer, buff_len-1, "%x", date);
|
g_date_strftime (buffer, buff_len-1, "%x", date);
|
||||||
|
|
||||||
g_date_free (date);
|
g_date_free (date);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, buff_len - 1, "%d/%d/%d (invalid)", month + 1, day, year);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
calendar_set_detail (CalendarData *data,
|
calendar_set_detail (CalendarData *data,
|
||||||
|
Loading…
Reference in New Issue
Block a user