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:
parent
0fd763bb25
commit
cd58b85b42
@ -2606,14 +2606,17 @@ 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
|
||||||
self.tooltip_timeout_id = None
|
finally:
|
||||||
|
# Always clear the ID to prevent trying to remove an invalid source later
|
||||||
|
self.tooltip_timeout_id = None
|
||||||
|
|
||||||
# Hide existing tooltip
|
# Hide existing tooltip
|
||||||
if self.tooltip_window:
|
if self.tooltip_window:
|
||||||
@ -2645,14 +2648,17 @@ 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
|
||||||
self.tooltip_timeout_id = None
|
finally:
|
||||||
|
# Always clear the ID to prevent trying to remove an invalid source later
|
||||||
|
self.tooltip_timeout_id = None
|
||||||
|
|
||||||
# Hide tooltip
|
# Hide tooltip
|
||||||
if self.tooltip_window:
|
if self.tooltip_window:
|
||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user