datetime: Don't crash when the timezone is unknown

Passing "posixrules" to cc_timezone_map_set_timezone() certainly
won't work that well.

https://bugzilla.redhat.com/show_bug.cgi?id=684593
This commit is contained in:
Bastien Nocera 2011-03-15 01:57:15 +00:00
parent 33fb810c84
commit 56cd9069ee

View file

@ -33,6 +33,8 @@
#include <libintl.h> #include <libintl.h>
#include <polkit/polkit.h> #include <polkit/polkit.h>
/* FIXME: This should be "Etc/GMT" instead */
#define DEFAULT_TZ "Europe/London"
#define GETTEXT_PACKAGE_TIMEZONES GETTEXT_PACKAGE "-timezones" #define GETTEXT_PACKAGE_TIMEZONES GETTEXT_PACKAGE "-timezones"
G_DEFINE_DYNAMIC_TYPE (CcDateTimePanel, cc_date_time_panel, CC_TYPE_PANEL) G_DEFINE_DYNAMIC_TYPE (CcDateTimePanel, cc_date_time_panel, CC_TYPE_PANEL)
@ -482,7 +484,11 @@ get_timezone_cb (CcDateTimePanel *self,
} }
else else
{ {
cc_timezone_map_set_timezone (CC_TIMEZONE_MAP (self->priv->map), timezone); if (!cc_timezone_map_set_timezone (CC_TIMEZONE_MAP (self->priv->map), timezone))
{
g_warning ("Timezone '%s' is unhandled, setting %s as default", timezone, DEFAULT_TZ);
cc_timezone_map_set_timezone (CC_TIMEZONE_MAP (self->priv->map), DEFAULT_TZ);
}
self->priv->current_location = cc_timezone_map_get_location (CC_TIMEZONE_MAP (self->priv->map)); self->priv->current_location = cc_timezone_map_get_location (CC_TIMEZONE_MAP (self->priv->map));
update_timezone (self); update_timezone (self);
} }