[libgweather/benzea/wip-variant-backend: 3/4] Add assertions that the world has been fully reset
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/benzea/wip-variant-backend: 3/4] Add assertions that the world has been fully reset
- Date: Sun, 26 Apr 2020 17:29:05 +0000 (UTC)
commit c1c67796ebf8cb5ce414a6c8a3f250193e4ec27d
Author: Benjamin Berg <bberg redhat com>
Date: Sun Apr 26 19:27:56 2020 +0200
Add assertions that the world has been fully reset
libgweather/gweather-location.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index f677426..1c3d4c3 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -278,11 +278,28 @@ static void _gweather_location_unref_no_check (GWeatherLocation *loc);
GWEATHER_EXTERN void
_gweather_location_reset_world (void)
{
+ gsize i;
g_return_if_fail (world_db);
/* Clear objects that need to be kept alive for the old API. */
g_ptr_array_set_size (world_db->locations_keepalive, 0);
g_ptr_array_set_size (world_db->timezones_keepalive, 0);
+
+ /* At this point, we had a leak if the caches are not completely empty. */
+ for (i = 0; i < world_db->locations->len; i++) {
+ if (G_UNLIKELY (g_ptr_array_index (world_db->locations, i) != NULL)) {
+ g_warning ("Location with index %li and name %s is still referenced!",
+ i, gweather_location_get_name (g_ptr_array_index (world_db->locations,
i)));
+ g_assert_not_reached ();
+ }
+ }
+ for (i = 0; i < world_db->timezones->len; i++) {
+ if (G_UNLIKELY (g_ptr_array_index (world_db->timezones, i) != NULL)) {
+ g_warning ("Timezone with index %li and tzid %s is still referenced!",
+ i, gweather_timezone_get_tzid (g_ptr_array_index (world_db->timezones,
i)));
+ g_assert_not_reached ();
+ }
+ }
}
static GWeatherLocation *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]