File tree 2 files changed +5
-4
lines changed
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -67,13 +67,9 @@ def draw_idle(self):
67
67
68
68
def _single_shot_timer (self , callback ):
69
69
"""Add a single shot timer with the given callback"""
70
- # We need to explicitly stop and remove the timer after
71
- # firing, otherwise segfaults will occur when trying to deallocate
72
- # the singleshot timers.
73
70
def callback_func (callback , timer ):
74
71
callback ()
75
72
self ._timers .remove (timer )
76
- timer .stop ()
77
73
timer = self .new_timer (interval = 0 )
78
74
timer .single_shot = True
79
75
timer .add_callback (callback_func , callback , timer )
Original file line number Diff line number Diff line change @@ -1746,6 +1746,11 @@ - (void)flagsChanged:(NSEvent *)event
1746
1746
repeats: !single
1747
1747
block: ^(NSTimer *timer) {
1748
1748
gil_call_method ((PyObject*)self, " _on_timer" );
1749
+ if (single) {
1750
+ // A single-shot timer will be automatically invalidated when it fires, so
1751
+ // we shouldn't do it ourselves when the object is deleted.
1752
+ self->timer = NULL ;
1753
+ }
1749
1754
}];
1750
1755
// Schedule the timer on the main run loop which is needed
1751
1756
// when updating the UI from a background thread
You can’t perform that action at this time.
0 commit comments