From 5f3960b171fd9dcea75022e670c7ac48f44e7928 Mon Sep 17 00:00:00 2001 From: Nikos Tsipinakis Date: Thu, 15 Nov 2018 13:42:05 +0200 Subject: [PATCH] Fix id replacement not assigning id if no notification has it In previous releases when a replace request came in with an id that doesn't exist we created a new notification with it anyway. This is used by some to imitate the behaviour of `stack_tag` and while not recommended (as it will break if another notification gets assigned that id) we want to avoid such subtle breakages without consideration. This bug was introduced in d879d70da060ea78fe735d62249a0afdf3e61bc8. --- src/queues.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/queues.c b/src/queues.c index 8ee0243..6597247 100644 --- a/src/queues.c +++ b/src/queues.c @@ -124,8 +124,6 @@ static bool queues_notification_is_ready(const struct notification *n, bool full /* see queues.h */ int queues_notification_insert(struct notification *n) { - bool inserted = false; - /* do not display the message, if the message is empty */ if (STR_EMPTY(n->msg)) { if (settings.always_run_script) { @@ -148,15 +146,23 @@ int queues_notification_insert(struct notification *n) return 0; } - if (!inserted && n->id != 0 && queues_notification_replace_id(n)) + bool inserted = false; + if (n->id != 0) { + if (!queues_notification_replace_id(n)) { + // Requested id was not valid, but play nice and assign it anyway + g_queue_insert_sorted(waiting, n, notification_cmp_data, NULL); + } inserted = true; - else + } else { n->id = ++next_notification_id; + } if (!inserted && STR_FULL(n->stack_tag) && queues_stack_by_tag(n)) inserted = true; + if (!inserted && settings.stack_duplicates && queues_stack_duplicate(n)) inserted = true; + if (!inserted) g_queue_insert_sorted(waiting, n, notification_cmp_data, NULL);