From cd58b85b42b64ca20bcec1e4d08a5f11ebc5d1fa Mon Sep 17 00:00:00 2001 From: Daniel Viegas Date: Sun, 30 Nov 2025 01:39:57 +0100 Subject: [PATCH] Fix: Clear timeout_id in show_tooltip to prevent double removal warnings - Clear tooltip_timeout_id at start of show_tooltip callback - Prevents attempting to remove timeout that already fired and was auto-removed - Simplifies removal logic by always clearing ID in finally block This fixes the GLib warning when timeout fires and is automatically removed, then we try to remove it again manually. --- MyTimeline.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/MyTimeline.py b/MyTimeline.py index a55fb5f..7fefa07 100644 --- a/MyTimeline.py +++ b/MyTimeline.py @@ -2606,14 +2606,17 @@ class MyTimelineView(NavigationView): # Cancel existing tooltip timeout if self.tooltip_timeout_id: - # source_remove returns True if successful, False if source not found - # Suppress the warning by checking return value (but warning may still occur) + # Try to remove the timeout source + # Note: If the timeout already fired, it's automatically removed and this will log a warning + # but we clear the ID anyway to prevent future attempts try: - removed = GLib.source_remove(self.tooltip_timeout_id) + GLib.source_remove(self.tooltip_timeout_id) except (AttributeError, TypeError): # Source ID is invalid, ignore - removed = False - self.tooltip_timeout_id = None + pass + finally: + # Always clear the ID to prevent trying to remove an invalid source later + self.tooltip_timeout_id = None # Hide existing tooltip if self.tooltip_window: @@ -2645,14 +2648,17 @@ class MyTimelineView(NavigationView): # Cancel tooltip timeout if self.tooltip_timeout_id: - # source_remove returns True if successful, False if source not found - # Suppress the warning by checking return value (but warning may still occur) + # Try to remove the timeout source + # Note: If the timeout already fired, it's automatically removed and this will log a warning + # but we clear the ID anyway to prevent future attempts try: - removed = GLib.source_remove(self.tooltip_timeout_id) + GLib.source_remove(self.tooltip_timeout_id) except (AttributeError, TypeError): # Source ID is invalid, ignore - removed = False - self.tooltip_timeout_id = None + pass + finally: + # Always clear the ID to prevent trying to remove an invalid source later + self.tooltip_timeout_id = None # Hide tooltip if self.tooltip_window: @@ -2878,6 +2884,10 @@ class MyTimelineView(NavigationView): Returns: bool: False to indicate the timeout should not be repeated. """ + # Clear timeout_id since this callback firing means the timeout was removed + # This prevents trying to remove it again later + self.tooltip_timeout_id = None + if event_index is None or event_index >= len(self.events): return False