summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2020-04-26 21:32:26 +0200
committerBenjamin Berg <bberg@redhat.com>2021-01-11 18:01:27 +0100
commit88bc056cff7188cdb27cdd7ab00af29347c0cca5 (patch)
treeaaa767667e5bb7f522453fd64cad9900d54435fe
parentabf8efd609658bf3c1b4fb132a8d8ee10823b3ac (diff)
downloadlibgweather-88bc056cff7188cdb27cdd7ab00af29347c0cca5.tar.gz
location-entry: Port location entry to new iteration API
So that it doesn't cause the whole world to be kept in memory forever.
-rw-r--r--libgweather/gweather-location-entry.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/libgweather/gweather-location-entry.c b/libgweather/gweather-location-entry.c
index b429b18..6eecfd6 100644
--- a/libgweather/gweather-location-entry.c
+++ b/libgweather/gweather-location-entry.c
@@ -489,11 +489,8 @@ fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
const char *parent_compare_english_name,
gboolean show_named_timezones)
{
- GWeatherLocation **children;
+ g_autoptr(GWeatherLocation) child = NULL;
char *display_name, *local_compare_name, *english_compare_name;
- int i;
-
- children = gweather_location_get_children (loc);
switch (gweather_location_get_level (loc)) {
case GWEATHER_LOCATION_WORLD:
@@ -501,24 +498,22 @@ fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
/* Ignore these levels of hierarchy; just recurse, passing on
* the names from the parent node.
*/
- for (i = 0; children[i]; i++) {
- fill_location_entry_model (store, children[i],
+ while ((child = gweather_location_next_child (loc, child)))
+ fill_location_entry_model (store, child,
parent_display_name,
parent_compare_local_name,
parent_compare_english_name,
show_named_timezones);
- }
break;
case GWEATHER_LOCATION_COUNTRY:
/* Recurse, initializing the names to the country name */
- for (i = 0; children[i]; i++) {
- fill_location_entry_model (store, children[i],
+ while ((child = gweather_location_next_child (loc, child)))
+ fill_location_entry_model (store, child,
gweather_location_get_name (loc),
gweather_location_get_sort_name (loc),
gweather_location_get_english_sort_name (loc),
show_named_timezones);
- }
break;
case GWEATHER_LOCATION_ADM1:
@@ -531,11 +526,10 @@ fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
local_compare_name = g_strdup_printf ("%s, %s", gweather_location_get_sort_name (loc), parent_compare_local_name);
english_compare_name = g_strdup_printf ("%s, %s", gweather_location_get_english_sort_name (loc), parent_compare_english_name);
- for (i = 0; children[i]; i++) {
- fill_location_entry_model (store, children[i],
+ while ((child = gweather_location_next_child (loc, child)))
+ fill_location_entry_model (store, child,
display_name, local_compare_name, english_compare_name,
show_named_timezones);
- }
g_free (display_name);
g_free (local_compare_name);