[gnome-clocks/zbrown/more-impossible-locations] world: fail early on non-existant places
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/zbrown/more-impossible-locations] world: fail early on non-existant places
- Date: Mon, 8 Jun 2020 01:16:47 +0000 (UTC)
commit b281fa74f91a1772d8e5b102bde3e06aae1a0da9
Author: Zander Brown <zbrown gnome org>
Date: Mon Jun 8 02:16:21 2020 +0100
world: fail early on non-existant places
GWeather is weird and weird stuff can and will happen, we've already got to a point where stuff like this
doesn't crash now we avoid endless critical logs as well
src/world.vala | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/world.vala b/src/world.vala
index d6fc8a6..8819af7 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -279,7 +279,8 @@ public class Item : Object, ContentItem {
if (weather_time_zone != null) {
time_zone = new GLib.TimeZone ((string) weather_time_zone);
if (time_zone == null) {
- warning ("Unrecognised timezone %s", (string) weather_time_zone);
+ warning ("Unrecognised timezone %s",
+ (string) weather_time_zone);
}
} else {
warning ("Failed to get a timezone for %s", location.get_name ());
@@ -457,7 +458,15 @@ public class Item : Object, ContentItem {
}
}
- return location == null ? null : (Item?) new Item ((GWeather.Location) location);
+ if (location == null) {
+ return null;
+ } else if (((GWeather.Location) location).get_timezone_str () == null) {
+ warning ("Invalid location ā%sā ā timezone unknown. Ignoring.",
+ ((GWeather.Location) location).get_name ());
+ return null;
+ } else {
+ return new Item ((GWeather.Location) location);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]