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.
This commit is contained in:
Daniel Viegas 2025-11-30 01:39:57 +01:00
parent 0fd763bb25
commit cd58b85b42

View File

@ -2606,13 +2606,16 @@ class MyTimelineView(NavigationView):
# Cancel existing tooltip timeout # Cancel existing tooltip timeout
if self.tooltip_timeout_id: if self.tooltip_timeout_id:
# source_remove returns True if successful, False if source not found # Try to remove the timeout source
# Suppress the warning by checking return value (but warning may still occur) # 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: try:
removed = GLib.source_remove(self.tooltip_timeout_id) GLib.source_remove(self.tooltip_timeout_id)
except (AttributeError, TypeError): except (AttributeError, TypeError):
# Source ID is invalid, ignore # Source ID is invalid, ignore
removed = False pass
finally:
# Always clear the ID to prevent trying to remove an invalid source later
self.tooltip_timeout_id = None self.tooltip_timeout_id = None
# Hide existing tooltip # Hide existing tooltip
@ -2645,13 +2648,16 @@ class MyTimelineView(NavigationView):
# Cancel tooltip timeout # Cancel tooltip timeout
if self.tooltip_timeout_id: if self.tooltip_timeout_id:
# source_remove returns True if successful, False if source not found # Try to remove the timeout source
# Suppress the warning by checking return value (but warning may still occur) # 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: try:
removed = GLib.source_remove(self.tooltip_timeout_id) GLib.source_remove(self.tooltip_timeout_id)
except (AttributeError, TypeError): except (AttributeError, TypeError):
# Source ID is invalid, ignore # Source ID is invalid, ignore
removed = False pass
finally:
# Always clear the ID to prevent trying to remove an invalid source later
self.tooltip_timeout_id = None self.tooltip_timeout_id = None
# Hide tooltip # Hide tooltip
@ -2878,6 +2884,10 @@ class MyTimelineView(NavigationView):
Returns: Returns:
bool: False to indicate the timeout should not be repeated. 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): if event_index is None or event_index >= len(self.events):
return False return False