diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2017-05-22 08:39:45 -0700 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2017-05-22 08:43:31 -0700 |
commit | bbe6f7c1c85628336536bcec6684d281656a3739 (patch) | |
tree | 0dbcedfed68cf42dfa756d8676a7edaab3138d7f | |
parent | ce3c858721c876cba7de2814c7f84addb1d5cb50 (diff) | |
download | libgweather-bbe6f7c1c85628336536bcec6684d281656a3739.tar.gz |
Fix refcounting bug in GWeatherInfo
The return value of find_by_station_code() is transfer none, but
GWeatherInfo would take ownership of it.
-rw-r--r-- | libgweather/gweather-weather.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c index 20b8c58..7d12b04 100644 --- a/libgweather/gweather-weather.c +++ b/libgweather/gweather-weather.c @@ -1992,7 +1992,7 @@ gweather_info_get_value_visibility (GWeatherInfo *info, static void gweather_info_set_location_internal (GWeatherInfo *info, - GWeatherLocation *location) + GWeatherLocation *location) { GWeatherInfoPrivate *priv = info->priv; GVariant *default_loc = NULL; @@ -2000,26 +2000,31 @@ gweather_info_set_location_internal (GWeatherInfo *info, gboolean latlon_override = FALSE; gdouble lat, lon; + if (priv->glocation == location) + return; + if (priv->glocation) gweather_location_unref (priv->glocation); priv->glocation = location; if (priv->glocation) { - gweather_location_ref (location); + gweather_location_ref (location); } else { - GWeatherLocation *world; - const gchar *station_code; + GWeatherLocation *world; + const gchar *station_code; - default_loc = g_settings_get_value (priv->settings, DEFAULT_LOCATION); + default_loc = g_settings_get_value (priv->settings, DEFAULT_LOCATION); - g_variant_get (default_loc, "(&s&sm(dd))", &name, &station_code, &latlon_override, &lat, &lon); + g_variant_get (default_loc, "(&s&sm(dd))", &name, &station_code, &latlon_override, &lat, &lon); if (strcmp(name, "") == 0) name = NULL; world = gweather_location_get_world (); priv->glocation = gweather_location_find_by_station_code (world, station_code); + if (priv->glocation) + gweather_location_ref (priv->glocation); } if (priv->glocation) { |