[gnome-applets] invest-applet: Stock data are not lost when update fails.



commit 0c6e9598985e73df677abd7f2148e5ea9ad2bb3d
Author: Enrico Minack <enrico-minack gmx de>
Date:   Thu Sep 10 18:42:32 2009 +0200

    invest-applet: Stock data are not lost when update fails.
    
    When the update fails due to lost internet connection, the
    applet could no longer show the latest stock data, see Bug #592377.
    This patch fixes this bug.

 invest-applet/invest/quotes.py |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/invest-applet/invest/quotes.py b/invest-applet/invest/quotes.py
index a66a954..09d0f3a 100644
--- a/invest-applet/invest/quotes.py
+++ b/invest-applet/invest/quotes.py
@@ -65,6 +65,7 @@ class QuotesRetriever(Thread, _IdleObject):
 class QuoteUpdater(gtk.ListStore):
 	updated = False
 	last_updated = None
+	quotes_valid = False
 	SYMBOL, LABEL, TICKER_ONLY, BALANCE, BALANCE_PCT, VALUE, VARIATION_PCT, PB = range(8)
 	def __init__ (self, change_icon_callback, set_tooltip_callback):
 		gtk.ListStore.__init__ (self, gobject.TYPE_STRING, gobject.TYPE_STRING, bool, float, float, float, float, gtk.gdk.Pixbuf)
@@ -83,8 +84,6 @@ class QuoteUpdater(gtk.ListStore):
 		quotes_retriever.connect("completed", self.on_retriever_completed)
 		quotes_retriever.start()
 
-		self.quotes_valid = False
-
 		return True
 
 
@@ -133,14 +132,11 @@ class QuoteUpdater(gtk.ListStore):
 		return result
 
 	def populate(self, quotes):
-		self.clear()
-
 		if (len(quotes) == 0):
-			self.quotes_valid = False
 			return
-		else:
-			self.quotes_valid = True
 
+		self.clear()
+		
 		try:
 			quote_items = quotes.items ()
 			quote_items.sort ()
@@ -206,6 +202,10 @@ class QuoteUpdater(gtk.ListStore):
 			else:
 				positions_balance_sign = self.positions_balance/abs(self.positions_balance)
 				self.change_icon_callback(positions_balance_sign)
+				
+			# mark quotes to finally be valid
+			self.quotes_valid = True
+
 		except Exception, msg:
 			invest.debug("Failed to populate quotes: %s" % msg)
 			invest.debug(quotes)



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