libgweather r553 - in trunk: . libgweather
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: libgweather r553 - in trunk: . libgweather
- Date: Fri, 19 Dec 2008 12:33:19 +0000 (UTC)
Author: mcrha
Date: Fri Dec 19 12:33:18 2008
New Revision: 553
URL: http://svn.gnome.org/viewvc/libgweather?rev=553&view=rev
Log:
2008-12-19 Milan Crha <mcrha redhat com>
** Part of fix for bug #564652
* libgweather/weather-iwin.c:
* libgweather/gweather-xml.h:
* libgweather/gweather-xml.c:
Do not copy soup session information for a forecast list. Check for
a forecast list information even without 'zone' of a 'location'.
Leak a bit less; new function 'gweather_xml_free_locations' to help
with this.
Modified:
trunk/ChangeLog
trunk/libgweather/gweather-xml.c
trunk/libgweather/gweather-xml.h
trunk/libgweather/weather-iwin.c
Modified: trunk/libgweather/gweather-xml.c
==============================================================================
--- trunk/libgweather/gweather-xml.c (original)
+++ trunk/libgweather/gweather-xml.c Fri Dec 19 12:33:18 2008
@@ -108,7 +108,7 @@
store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
if (!gweather_xml_parse_node (world, store, NULL)) {
- g_object_unref (store);
+ gweather_xml_free_locations ((GtkTreeModel *)store);
store = NULL;
}
@@ -116,3 +116,33 @@
return (GtkTreeModel *)store;
}
+
+static gboolean
+free_locations (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+ WeatherLocation *loc = NULL;
+
+ gtk_tree_model_get (model, iter,
+ GWEATHER_XML_COL_POINTER, &loc,
+ -1);
+
+ if (loc) {
+ weather_location_free (loc);
+ gtk_tree_store_set ((GtkTreeStore *)model, iter,
+ GWEATHER_XML_COL_POINTER, NULL,
+ -1);
+ }
+
+ return FALSE;
+}
+
+/* Frees model returned from @gweather_xml_load_locations. It contains allocated
+ WeatherLocation-s, thus this takes care of the freeing of that memory. */
+void
+gweather_xml_free_locations (GtkTreeModel *locations)
+{
+ if (locations && GTK_IS_TREE_STORE (locations)) {
+ gtk_tree_model_foreach (locations, free_locations, NULL);
+ g_object_unref (locations);
+ }
+}
Modified: trunk/libgweather/gweather-xml.h
==============================================================================
--- trunk/libgweather/gweather-xml.h (original)
+++ trunk/libgweather/gweather-xml.h Fri Dec 19 12:33:18 2008
@@ -32,5 +32,6 @@
};
GtkTreeModel *gweather_xml_load_locations (void);
+void gweather_xml_free_locations (GtkTreeModel *locations);
#endif /* __GWEATHER_XML_H__ */
Modified: trunk/libgweather/weather-iwin.c
==============================================================================
--- trunk/libgweather/weather-iwin.c (original)
+++ trunk/libgweather/weather-iwin.c Fri Dec 19 12:33:18 2008
@@ -102,14 +102,14 @@
g_return_val_if_fail (master_info != NULL, NULL);
if (!buff || !*buff)
- return NULL;
+ return NULL;
#define XC (const xmlChar *)
#define isElem(_node,_name) g_str_equal ((const char *)_node->name, _name)
doc = xmlParseMemory (buff, strlen (buff));
if (!doc)
- return NULL;
+ return NULL;
/* Description at http://www.weather.gov/mdl/XML/Design/MDL_XML_Design.pdf */
root = xmlDocGetRootElement (doc);
@@ -143,15 +143,10 @@
xmlChar *val = xmlNodeGetContent (c);
if (val) {
- struct tm t;
- char sign;
- int gmt1 = 0, gmt2 = 0;
-
- memset (&t, 0, sizeof (struct tm));
- if (sscanf ((const char *)val, "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec, &sign, &gmt1, &gmt2) == 9) {
- t.tm_mon--;
- t.tm_year -= 1900;
- update_times[count] = mktime (&t) + ((sign == '-' ? -1 : 1) * ((60 * gmt1) + gmt2) * 60);
+ GTimeVal tv;
+
+ if (g_time_val_from_iso8601 ((const char *)val, &tv)) {
+ update_times[count] = tv.tv_sec;
} else {
update_times[count] = 0;
}
@@ -206,6 +201,10 @@
nfo->sunset = 0;
g_free (nfo->forecast);
nfo->forecast = NULL;
+ nfo->session = NULL;
+ nfo->requests_pending = 0;
+ nfo->finish_cb = NULL;
+ nfo->cb_data = NULL;
res = g_slist_append (res, nfo);
}
}
@@ -226,7 +225,7 @@
xmlChar *val = xmlNodeGetContent (c);
/* can pass some values as <value xsi:nil="true"/> */
- if (!val) {
+ if (!val || !*val) {
if (is_max)
nfo->temp_max = nfo->temp_min;
else
@@ -236,9 +235,10 @@
nfo->temp_max = atof ((const char *)val);
else
nfo->temp_min = atof ((const char *)val);
+ }
+ if (val)
xmlFree (val);
- }
nfo->tempMinMaxValid = nfo->tempMinMaxValid || (nfo->temp_max > -999.0 && nfo->temp_min > -999.0);
nfo->valid = nfo->tempMinMaxValid;
@@ -322,6 +322,9 @@
}
}
+ if (val)
+ xmlFree (val);
+
at = at->next;
}
}
@@ -410,7 +413,7 @@
loc = info->location;
g_return_if_fail (loc != NULL);
- if (loc->zone[0] == '-')
+ if (loc->zone[0] == '-' && (info->forecast_type != FORECAST_LIST || !loc->latlon_valid))
return;
if (info->forecast) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]