WeatherClient: set enabled providers after setting a valid location
So far, the GWeatherInfo was given the enabled weather providers as a parameter, at construction time. Because of the way in which libgweather was designed, setting the providers right from the beginning enabled libgweather to use them internally in order to update its state. Updating the internal state is only relevant when there is a valid location set, which is not guaranteed at the time when the GWeatherInfo object is constructed. In order to fix this, enable no providers at construction time and only set valid providers after setting a valid location. https://bugzilla.gnome.org/show_bug.cgi?id=780404
This commit is contained in:
parent
fcbb942e24
commit
8e443a2aff
@ -54,10 +54,11 @@ const WeatherClient = new Lang.Class({
|
|||||||
|
|
||||||
this._world = GWeather.Location.get_world();
|
this._world = GWeather.Location.get_world();
|
||||||
|
|
||||||
let providers = GWeather.Provider.METAR |
|
this._providers = GWeather.Provider.METAR |
|
||||||
GWeather.Provider.YR_NO |
|
GWeather.Provider.YR_NO |
|
||||||
GWeather.Provider.OWM;
|
GWeather.Provider.OWM;
|
||||||
this._weatherInfo = new GWeather.Info({ enabled_providers: providers });
|
|
||||||
|
this._weatherInfo = new GWeather.Info({ enabled_providers: 0 });
|
||||||
this._weatherInfo.connect_after('updated', () => {
|
this._weatherInfo.connect_after('updated', () => {
|
||||||
this._lastUpdate = GLib.DateTime.new_now_local();
|
this._lastUpdate = GLib.DateTime.new_now_local();
|
||||||
this.emit('changed');
|
this.emit('changed');
|
||||||
@ -141,6 +142,8 @@ const WeatherClient = new Lang.Class({
|
|||||||
this._weatherInfo.set_location(location);
|
this._weatherInfo.set_location(location);
|
||||||
this._locationValid = (location != null);
|
this._locationValid = (location != null);
|
||||||
|
|
||||||
|
this._weatherInfo.set_enabled_providers(location ? this._providers : 0);
|
||||||
|
|
||||||
if (location)
|
if (location)
|
||||||
this._loadInfo();
|
this._loadInfo();
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user