From b7677affeb0eaa9dd36edc9a4029e13844a435e3 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Thu, 26 Oct 2017 20:26:25 +0200 Subject: [PATCH] Free notifications ignored in history Notifications having set the history_ignore hint (and by default also transient notifications) have not been freed. --- src/queues.c | 24 +++++++++++++++--------- src/queues.h | 8 +++++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/queues.c b/src/queues.c index c6316a8..0bad405 100644 --- a/src/queues.c +++ b/src/queues.c @@ -188,7 +188,6 @@ int queues_notification_close_id(int id, int reason) notification *n = iter->data; if (n->id == id) { g_queue_remove(displayed, n); - queues_history_push(n); target = n; break; } @@ -198,15 +197,19 @@ int queues_notification_close_id(int id, int reason) iter = iter->next) { notification *n = iter->data; if (n->id == id) { + assert(target == NULL); g_queue_remove(waiting, n); - queues_history_push(n); target = n; break; } } - if (reason > 0 && reason < 4 && target != NULL) { - notification_closed(target, reason); + if (target) { + + if (reason > 0 && reason < 4) + notification_closed(target, reason); + + queues_history_push(target); } return reason; @@ -232,13 +235,16 @@ void queues_history_pop(void) void queues_history_push(notification *n) { - if (settings.history_length > 0 && history->length >= settings.history_length) { - notification *to_free = g_queue_pop_head(history); - notification_free(to_free); - } + if (!n->history_ignore) { + if (settings.history_length > 0 && history->length >= settings.history_length) { + notification *to_free = g_queue_pop_head(history); + notification_free(to_free); + } - if (!n->history_ignore) g_queue_push_tail(history, n); + } else { + notification_free(n); + } } void queues_history_push_all(void) diff --git a/src/queues.h b/src/queues.h index 8cec5fc..d318180 100644 --- a/src/queues.h +++ b/src/queues.h @@ -67,7 +67,11 @@ bool queues_notification_replace_id(notification *new); */ int queues_notification_close_id(int id, int reason); -/* Close the given notification. SEE queues_notification_close_id. */ +/* Close the given notification. SEE queues_notification_close_id. + * + * @n: (transfer full): The notification to close + * @reason: The reason to close + * */ int queues_notification_close(notification *n, int reason); /* @@ -79,6 +83,8 @@ void queues_history_pop(void); /* * Push a single notification to history * The given notification has to be removed its queue + * + * @n: (transfer full): The notification to push to history */ void queues_history_push(notification *n);