File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -391,9 +391,20 @@ static CGFloat _get_device_scale(CGContextRef cr)
391391static PyObject*
392392FigureCanvas_flush_events (FigureCanvas* self)
393393{
394- // We need to allow the runloop to run very briefly
395- // to allow the view to be displayed when used in a fast updating animation
396- [[NSRunLoop currentRunLoop ] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.0 ]];
394+ // We run the app, matching any events that are waiting in the queue
395+ // to process, breaking out of the loop when no events remain and
396+ // displaying the canvas if needed.
397+ NSEvent *event;
398+ while (true ) {
399+ event = [NSApp nextEventMatchingMask: NSEventMaskAny
400+ untilDate: [NSDate distantPast ]
401+ inMode: NSDefaultRunLoopMode
402+ dequeue: YES ];
403+ if (!event) {
404+ break ;
405+ }
406+ [NSApp sendEvent: event];
407+ }
397408 [self ->view displayIfNeeded ];
398409 Py_RETURN_NONE;
399410}
You can’t perform that action at this time.
0 commit comments