[gnome-todo/feature/unref-fixes: 1/2] background: Use g_autoptr to fix some leaks




commit 568daf9a9416e0aad20093fc7250ed955fe0938f
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Fri Oct 8 19:07:27 2021 +0200

    background: Use g_autoptr to fix some leaks
    
    We were leaking some `GDateTime`s and a few strings. This commit cleans
    it up with g_autoptr().

 src/plugins/background/gtd-plugin-background.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/background/gtd-plugin-background.c b/src/plugins/background/gtd-plugin-background.c
index 01340154..cf48786c 100644
--- a/src/plugins/background/gtd-plugin-background.c
+++ b/src/plugins/background/gtd-plugin-background.c
@@ -286,8 +286,8 @@ get_tasks_for_today (guint *n_events)
 
       for (j = 0; j < g_list_model_get_n_items (list); j++)
         {
-          GDateTime *due_date;
-          GtdTask *task;
+          g_autoptr (GtdTask) task = NULL;
+          g_autoptr (GDateTime) due_date = NULL;
 
           task = g_list_model_get_item (list, j);
 
@@ -310,13 +310,13 @@ get_tasks_for_today (guint *n_events)
 static void
 send_notification (GtdPluginBackground *self)
 {
-  GNotification *notification;
+  g_autoptr (GNotification) notification = NULL;
   GApplication *app;
   GtdWindow *window;
   guint n_tasks;
-  GList *tasks;
-  gchar *title;
-  gchar *body;
+  g_autoptr (GList) tasks = NULL;
+  g_autofree char *title = NULL;
+  g_autofree char *body = NULL;
 
   window = GTD_WINDOW (get_window ());
 
@@ -352,9 +352,6 @@ send_notification (GtdPluginBackground *self)
   g_notification_set_default_action (notification, "app.activate");
 
   g_application_send_notification (app, AUTOSTART_NOTIFICATION_ID, notification);
-
-  g_clear_pointer (&tasks, g_list_free);
-  g_clear_object (&notification);
 }
 
 /*


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]