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

Appearance settings

Commit b2f72f9

Browse filesBrowse files
committed
FIX: Add macos timers to the main thread
The macos timers need to be explicitly added to the main runloop so the drawing takes place there. This causes issues if updating data from other threads and wanting the plot to update.
1 parent 9b43515 commit b2f72f9
Copy full SHA for b2f72f9

File tree

Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed

‎src/_macosx.m

Copy file name to clipboardExpand all lines: src/_macosx.m
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,11 +1726,15 @@ - (void)flagsChanged:(NSEvent *)event
17261726
}
17271727

17281728
// hold a reference to the timer so we can invalidate/stop it later
1729-
self->timer = [NSTimer scheduledTimerWithTimeInterval: interval
1730-
repeats: !single
1731-
block: ^(NSTimer *timer) {
1729+
self->timer = [NSTimer timerWithTimeInterval: interval
1730+
repeats: !single
1731+
block: ^(NSTimer *timer) {
17321732
gil_call_method((PyObject*)self, "_on_timer");
17331733
}];
1734+
// Schedule the timer on the main run loop which is needed
1735+
// when updating the UI from a background thread
1736+
[[NSRunLoop mainRunLoop] addTimer: self->timer forMode: NSRunLoopCommonModes];
1737+
17341738
exit:
17351739
Py_XDECREF(py_interval);
17361740
Py_XDECREF(py_single);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.