Merge pull request #425 from bebehei/memory-leak_history-ignore

Free notifications ignored in history
This commit is contained in:
Nikos Tsipinakis 2017-11-07 13:53:22 +02:00 committed by GitHub
commit 62e50289f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 10 deletions

View File

@ -188,7 +188,6 @@ int queues_notification_close_id(int id, int reason)
notification *n = iter->data; notification *n = iter->data;
if (n->id == id) { if (n->id == id) {
g_queue_remove(displayed, n); g_queue_remove(displayed, n);
queues_history_push(n);
target = n; target = n;
break; break;
} }
@ -198,15 +197,19 @@ int queues_notification_close_id(int id, int reason)
iter = iter->next) { iter = iter->next) {
notification *n = iter->data; notification *n = iter->data;
if (n->id == id) { if (n->id == id) {
assert(target == NULL);
g_queue_remove(waiting, n); g_queue_remove(waiting, n);
queues_history_push(n);
target = n; target = n;
break; break;
} }
} }
if (reason > 0 && reason < 4 && target != NULL) { if (target) {
if (reason > 0 && reason < 4)
notification_closed(target, reason); notification_closed(target, reason);
queues_history_push(target);
} }
return reason; return reason;
@ -232,13 +235,16 @@ void queues_history_pop(void)
void queues_history_push(notification *n) void queues_history_push(notification *n)
{ {
if (!n->history_ignore) {
if (settings.history_length > 0 && history->length >= settings.history_length) { if (settings.history_length > 0 && history->length >= settings.history_length) {
notification *to_free = g_queue_pop_head(history); notification *to_free = g_queue_pop_head(history);
notification_free(to_free); notification_free(to_free);
} }
if (!n->history_ignore)
g_queue_push_tail(history, n); g_queue_push_tail(history, n);
} else {
notification_free(n);
}
} }
void queues_history_push_all(void) void queues_history_push_all(void)

View File

@ -67,7 +67,11 @@ bool queues_notification_replace_id(notification *new);
*/ */
int queues_notification_close_id(int id, int reason); 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); int queues_notification_close(notification *n, int reason);
/* /*
@ -79,6 +83,8 @@ void queues_history_pop(void);
/* /*
* Push a single notification to history * Push a single notification to history
* The given notification has to be removed its queue * The given notification has to be removed its queue
*
* @n: (transfer full): The notification to push to history
*/ */
void queues_history_push(notification *n); void queues_history_push(notification *n);