[gnome-panel/gnome-3-32] clock: fix handling of detached locations



commit 422215aeae49f411b62ba28518fc6575fe49dd4a
Author: Dmitry Shachnev <mitya57 gmail com>
Date:   Wed Dec 11 00:30:16 2019 +0300

    clock: fix handling of detached locations
    
    GWeatherLocationEntry sometimes returns locations with level
    GWEATHER_LOCATION_DETACHED. For such locations, weather_code is NULL
    and clock_location_new crashes if we pass such code to it.
    
    I can reproduce this by searching for "Riga" and selecting the first
    entry from suggestions.

 modules/clock/clock-applet.c | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/modules/clock/clock-applet.c b/modules/clock/clock-applet.c
index 3add9d3ab..6689b36cb 100644
--- a/modules/clock/clock-applet.c
+++ b/modules/clock/clock-applet.c
@@ -1316,6 +1316,11 @@ run_prefs_edit_save (GtkButton   *button,
         }
 
         station_loc = gloc;
+        if (gweather_location_get_level (station_loc) == GWEATHER_LOCATION_DETACHED) {
+                /* According to the documentation, the parent of a detached location is
+                 * the nearest weather station. */
+                station_loc = gweather_location_get_parent (station_loc);
+        }
         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);


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