gnome-panel r11437 - trunk/applets/clock



Author: vuntz
Date: Thu Jan  8 15:31:22 2009
New Revision: 11437
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=11437&view=rev

Log:
2009-01-08  Vincent Untz  <vuntz gnome org>

	* clock-location.c: (clock_location_new): use
	clock_location_get_valid_weather_code()
	(clock_location_get_valid_weather_code): new, to use "-" for empty code
	(clock_location_set_weather_code): use
	clock_location_get_valid_weather_code()
	(setup_weather_updates): update to use WEATHER_EMPTY_CODE
	Fix bug #560200 (crash on Solaris when the weather code is empty)


Modified:
   trunk/applets/clock/ChangeLog
   trunk/applets/clock/clock-location.c

Modified: trunk/applets/clock/clock-location.c
==============================================================================
--- trunk/applets/clock/clock-location.c	(original)
+++ trunk/applets/clock/clock-location.c	Thu Jan  8 15:31:22 2009
@@ -52,6 +52,7 @@
 
 #define WEATHER_TIMEOUT_BASE 30
 #define WEATHER_TIMEOUT_MAX  1800
+#define WEATHER_EMPTY_CODE   "-"
 
 enum {
 	WEATHER_UPDATED,
@@ -68,6 +69,8 @@
 static void add_to_network_monitor (ClockLocation *loc);
 static void remove_from_network_monitor (ClockLocation *loc);
 
+static gchar *clock_location_get_valid_weather_code (const gchar *code);
+
 #define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CLOCK_LOCATION_TYPE, ClockLocationPrivate))
 
 ClockLocation *
@@ -119,7 +122,7 @@
         priv->latitude = latitude;
         priv->longitude = longitude;
 
-        priv->weather_code = g_strdup (code);
+        priv->weather_code = clock_location_get_valid_weather_code (code);
 
 	if (prefs) {
 		priv->temperature_unit = prefs->temperature_unit;
@@ -538,6 +541,15 @@
         g_free (filename);
 }
 
+static gchar *
+clock_location_get_valid_weather_code (const gchar *code)
+{
+	if (!code || code[0] == '\0')
+		return g_strdup (WEATHER_EMPTY_CODE);
+	else
+		return g_strdup (code);
+}
+
 const gchar *
 clock_location_get_weather_code (ClockLocation *loc)
 {
@@ -552,7 +564,7 @@
         ClockLocationPrivate *priv = PRIVATE (loc);
 
 	g_free (priv->weather_code);
-	priv->weather_code = g_strdup (code);
+	priv->weather_code = clock_location_get_valid_weather_code (code);
 
 	setup_weather_updates (loc);
 }
@@ -807,7 +819,8 @@
 		priv->weather_timeout = 0;
 	}
 
-	if (!priv->weather_code || strcmp (priv->weather_code, "-") == 0)
+	if (!priv->weather_code ||
+	    strcmp (priv->weather_code, WEATHER_EMPTY_CODE) == 0)
 		return;
 
 	dms = rad2dms (priv->latitude, priv->longitude);



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