diff options
author | Benjamin Berg <bberg@redhat.com> | 2020-04-26 21:32:26 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-01-11 20:31:52 +0100 |
commit | ec0a2d5f7413b4a29f77107b294959be1ff8ae54 (patch) | |
tree | 52e813fa5bcf8b7fb10f4f9c8626dc7e8f57f33a /libgweather | |
parent | d8ddaf840a50cae33bfe32fdb3cfc8483ddad071 (diff) | |
download | libgweather-ec0a2d5f7413b4a29f77107b294959be1ff8ae54.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.
Diffstat (limited to 'libgweather')
-rw-r--r-- | libgweather/gweather-location-entry.c | 20 |
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); |