diff --git a/lib/matplotlib/backends/backend_macosx.py b/lib/matplotlib/backends/backend_macosx.py index 822cd22ba6c7..7f5589677d31 100644 --- a/lib/matplotlib/backends/backend_macosx.py +++ b/lib/matplotlib/backends/backend_macosx.py @@ -67,13 +67,9 @@ def draw_idle(self): def _single_shot_timer(self, callback): """Add a single shot timer with the given callback""" - # We need to explicitly stop and remove the timer after - # firing, otherwise segfaults will occur when trying to deallocate - # the singleshot timers. def callback_func(callback, timer): callback() self._timers.remove(timer) - timer.stop() timer = self.new_timer(interval=0) timer.single_shot = True timer.add_callback(callback_func, callback, timer) diff --git a/src/_macosx.m b/src/_macosx.m index 299fed1785a8..5f2b1ab8d195 100755 --- a/src/_macosx.m +++ b/src/_macosx.m @@ -1741,6 +1741,11 @@ - (void)flagsChanged:(NSEvent *)event repeats: !single block: ^(NSTimer *timer) { gil_call_method((PyObject*)self, "_on_timer"); + if (single) { + // A single-shot timer will be automatically invalidated when it fires, so + // we shouldn't do it ourselves when the object is deleted. + self->timer = NULL; + } }]; // Schedule the timer on the main run loop which is needed // when updating the UI from a background thread
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: