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