summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2021-10-08 19:07:27 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2021-10-08 19:21:42 +0200
commit568daf9a9416e0aad20093fc7250ed955fe0938f (patch)
tree991e7245ddbb7a686f039f7231e37f1fa701f2aa
parent5990e8c081a9ca55440d096c8e5517ce6584f6c8 (diff)
downloadgnome-todo-568daf9a9416e0aad20093fc7250ed955fe0938f.tar.gz
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().
-rw-r--r--src/plugins/background/gtd-plugin-background.c15
1 files 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);
}
/*