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