[gnome-clocks] Fix white screen when clicking newly added world clock.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Fix white screen when clicking newly added world clock.
- Date: Sun, 16 Sep 2012 14:06:07 +0000 (UTC)
commit 5ff8ff8f1ede3c57de9fd4a9717cf1f3f4f1c6ba
Author: MaÃl Lavault <mael lavault mailz org>
Date: Sun Sep 16 13:38:08 2012 +0200
Fix white screen when clicking newly added world clock.
Store the GWeather "world" object in a global singleton, otherwise when
it gets garbage collected calling get_city_name on a location fails.
https://bugzilla.gnome.org/show_bug.cgi?id=683234
gnomeclocks/world.py | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gnomeclocks/world.py b/gnomeclocks/world.py
index e4fbead..2964b41 100644
--- a/gnomeclocks/world.py
+++ b/gnomeclocks/world.py
@@ -27,10 +27,14 @@ from utils import Dirs, SystemSettings
from widgets import DigitalClockDrawing, SelectableIconView, ContentView
+# keep the GWeather world around as a singletom, otherwise
+# if is garbage collected get_city_name etc fail.
+gweather_world = GWeather.Location.new_world(True)
+
+
class WorldClockStorage():
def __init__(self):
self.filename = os.path.join(Dirs.get_user_data_dir(), "clocks.json")
- self.world = GWeather.Location.new_world(True)
def save(self, clocks):
location_codes = [c.location.get_code() for c in clocks]
@@ -45,7 +49,7 @@ class WorldClockStorage():
location_codes = json.load(f)
f.close()
for l in location_codes:
- location = GWeather.Location.find_by_station_code(self.world, l)
+ location = GWeather.Location.find_by_station_code(gweather_world, l)
if location:
clock = DigitalClock(location)
clocks.append(clock)
@@ -71,8 +75,7 @@ class NewWorldClockDialog(Gtk.Dialog):
label = Gtk.Label(_("Search for a city:"))
label.set_alignment(0.0, 0.5)
- world = GWeather.Location.new_world(True)
- self.entry = GWeather.LocationEntry.new(world)
+ self.entry = GWeather.LocationEntry.new(gweather_world)
self.find_gicon = Gio.ThemedIcon.new_with_default_fallbacks(
'edit-find-symbolic')
self.clear_gicon = Gio.ThemedIcon.new_with_default_fallbacks(
@@ -184,8 +187,7 @@ class DigitalClock():
self._last_time = t
def get_sunrise_sunset(self):
- world = GWeather.Location.new_world(True)
- self.weather = GWeather.Info(location=self.location, world=world)
+ self.weather = GWeather.Info(location=self.location, world=gweather_world)
self.weather.connect('updated', self._on_weather_updated)
self.weather.update()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]