From 7aa5d718a8d272560addb4282e12d5e43898e179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Mon, 18 Mar 2024 21:45:47 +0100 Subject: [PATCH] core: send signal "hotlist_changed" only if the order of hotlist has changed after sort (issue #2097) --- src/gui/gui-hotlist.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c index 7964dce94..9d661ad57 100644 --- a/src/gui/gui-hotlist.c +++ b/src/gui/gui-hotlist.c @@ -546,20 +546,25 @@ void gui_hotlist_resort () { struct t_gui_hotlist *new_hotlist, *last_new_hotlist; - struct t_gui_hotlist *ptr_hotlist, *ptr_next_hotlist; + struct t_gui_hotlist *ptr_hotlist, *ptr_next_hotlist, *ptr_prev_hotlist; + int hotlist_changed; /* sort is not needed if hotlist has less than 2 entries */ if (!gui_hotlist || !gui_hotlist->next_hotlist) return; /* resort hotlist in new linked list */ + hotlist_changed = 0; new_hotlist = NULL; last_new_hotlist = NULL; ptr_hotlist = gui_hotlist; while (ptr_hotlist) { ptr_next_hotlist = ptr_hotlist->next_hotlist; + ptr_prev_hotlist = ptr_hotlist->prev_hotlist; gui_hotlist_add_hotlist (&new_hotlist, &last_new_hotlist, ptr_hotlist); + if (ptr_hotlist->prev_hotlist != ptr_prev_hotlist) + hotlist_changed = 1; ptr_hotlist = ptr_next_hotlist; } @@ -567,7 +572,8 @@ gui_hotlist_resort () gui_hotlist = new_hotlist; last_gui_hotlist = last_new_hotlist; - gui_hotlist_changed_signal (NULL); + if (hotlist_changed) + gui_hotlist_changed_signal (NULL); } /*