diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-06-20 12:18:17 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-06-20 12:18:17 -0400 |
commit | 3fab2b55ccd43111f0ab8f839d03de5ebd75beda (patch) | |
tree | bbcaacb9bfd28f5f653a96598370f6d41cfd23eb /demos/gtk-demo | |
parent | 2842030e59692e7e943c6db246485711e02e3883 (diff) | |
download | gtk+-3fab2b55ccd43111f0ab8f839d03de5ebd75beda.tar.gz |
gtk-demo: Clean up memory handling in the weather demo
gtk_weather_info_new was consuming the info, but not
the timestamp, which confused me. Make it not consume
either, and be more explicit about where the unrefs
happen.
Diffstat (limited to 'demos/gtk-demo')
-rw-r--r-- | demos/gtk-demo/listview_weather.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/demos/gtk-demo/listview_weather.c b/demos/gtk-demo/listview_weather.c index c373e43686..4fa83721f4 100644 --- a/demos/gtk-demo/listview_weather.c +++ b/demos/gtk-demo/listview_weather.c @@ -70,7 +70,6 @@ gtk_weather_info_new (GDateTime *timestamp, { result->temperature = copy_from->temperature; result->weather_type = copy_from->weather_type; - g_object_unref (copy_from); } return result; @@ -161,6 +160,7 @@ create_weather_model (void) timestamp = g_date_time_new (utc, 2011, 1, 1, 0, 0, 0); info = gtk_weather_info_new (timestamp, NULL); g_list_store_append (store, info); + g_object_unref (info); for (i = 0; lines[i] != NULL && *lines[i]; i++) { @@ -176,6 +176,7 @@ create_weather_model (void) timestamp = new_timestamp; info = gtk_weather_info_new (timestamp, info); g_list_store_append (store, info); + g_object_unref (info); } info->temperature = parse_temperature (fields[1], info->temperature); @@ -184,6 +185,7 @@ create_weather_model (void) g_strfreev (fields); } + g_date_time_unref (timestamp); g_strfreev (lines); g_bytes_unref (data); g_time_zone_unref (utc); |