Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1004e03

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR#27875: macosx: Clean up single-shot timers correctly
1 parent3986012 commit1004e03

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

‎lib/matplotlib/backends/backend_macosx.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,9 @@ def draw_idle(self):
6464

6565
def_single_shot_timer(self,callback):
6666
"""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.
7067
defcallback_func(callback,timer):
7168
callback()
7269
self._timers.remove(timer)
73-
timer.stop()
7470
timer=self.new_timer(interval=0)
7571
timer.single_shot=True
7672
timer.add_callback(callback_func,callback,timer)

‎src/_macosx.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,11 @@ - (void)flagsChanged:(NSEvent *)event
17411741
repeats: !single
17421742
block: ^(NSTimer *timer) {
17431743
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+
}
17441749
}];
17451750
// Schedule the timer on the main run loop which is needed
17461751
// when updating the UI from a background thread

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp