[gnome-panel/gnome-3-8] Fix clock crash when adding new location



commit 8d7cb2b776a3a1f2612474605cad31e3c341caf6
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri May 23 17:11:11 2014 +0300

    Fix clock crash when adding new location

 applets/clock/clock.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index 68f20eb..41ffb9b 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -1440,7 +1440,7 @@ run_prefs_edit_save (GtkButton *button, ClockData *cd)
         const gchar *timezone, *weather_code;
         gchar *city, *name;
 
-        GWeatherLocation *gloc;
+        GWeatherLocation *gloc, *station_loc;
         gfloat lat = 0;
         gfloat lon = 0;
 
@@ -1465,7 +1465,13 @@ run_prefs_edit_save (GtkButton *button, ClockData *cd)
                 return;
         }
 
-        weather_code = gweather_location_get_code (gloc);
+        station_loc = gloc;
+        while (gweather_location_get_level (station_loc) < GWEATHER_LOCATION_WEATHER_STATION) {
+                station_loc = gweather_location_get_children (station_loc)[0];
+                g_assert (station_loc != NULL);
+        }
+
+        weather_code = gweather_location_get_code (station_loc);
         if (gweather_location_entry_has_custom_text (cd->location_entry)) {
                 name = gtk_editable_get_chars (GTK_EDITABLE (cd->location_entry), 0, -1);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]