Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32547c8

Browse files
committed
FIX: Add a 0-length timer to allow fast animations to redraw on macosx
The macosx backend would not update on flush_events calls due to the loop being run too fast for the view to update properly in the NSApp. Fix that by adding an unnoticeable RunLoop timer slowdown that allows the app to see the changes.
1 parent 4264233 commit 32547c8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/_macosx.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ static CGFloat _get_device_scale(CGContextRef cr)
354354
static PyObject*
355355
FigureCanvas_flush_events(FigureCanvas* self)
356356
{
357+
// We need to allow the runloop to run very briefly
358+
// to allow the view to be displayed when used in a fast updating animation
359+
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.0]];
357360
[self->view displayIfNeeded];
358361
Py_RETURN_NONE;
359362
}

0 commit comments

Comments
 (0)