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 45f4888

Browse filesBrowse files
authored
Merge pull request #27527 from greglucas/macos-timer-main
FIX: Add macos timers to the main thread
2 parents 5ffafd0 + b2f72f9 commit 45f4888
Copy full SHA for 45f4888

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
@@ -1723,11 +1723,15 @@ - (void)flagsChanged:(NSEvent *)event
17231723
}
17241724

17251725
// hold a reference to the timer so we can invalidate/stop it later
1726-
self->timer = [NSTimer scheduledTimerWithTimeInterval: interval
1727-
repeats: !single
1728-
block: ^(NSTimer *timer) {
1726+
self->timer = [NSTimer timerWithTimeInterval: interval
1727+
repeats: !single
1728+
block: ^(NSTimer *timer) {
17291729
gil_call_method((PyObject*)self, "_on_timer");
17301730
}];
1731+
// Schedule the timer on the main run loop which is needed
1732+
// when updating the UI from a background thread
1733+
[[NSRunLoop mainRunLoop] addTimer: self->timer forMode: NSRunLoopCommonModes];
1734+
17311735
exit:
17321736
Py_XDECREF(py_interval);
17331737
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.