From 820f3455a1fb4bd90c75fde4a08d85d41e7a80ac Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 22 May 2026 13:43:10 +0200 Subject: [PATCH] Fixed expired message cleaning sometimes targeting invalid indices --- nomadnet/ui/textui/Channels.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nomadnet/ui/textui/Channels.py b/nomadnet/ui/textui/Channels.py index 2bdb882..ae4f19c 100644 --- a/nomadnet/ui/textui/Channels.py +++ b/nomadnet/ui/textui/Channels.py @@ -785,9 +785,12 @@ class RoomWidget(urwid.WidgetWrap): else: o = None if hasattr(o, "msg"): msg = o.msg elif hasattr(w, "msg"): msg = w.msg - if msg and not msg in hub_msgs: old.add(i) + if msg and not msg in hub_msgs: old.add(w) - for i in reversed(list(old)): self.messagelist.delete_position(i) + list_body = self.messagelist.get_body() + for w in list(old): + try: list_body.remove(w) + except: RNS.log(f"Could not remove expired message widget {w}: {e}", RNS.LOG_DEBUG) except Exception as e: RNS.log("Error while cleaning room history", RNS.LOG_ERROR)