From 3851a8ff20c6aed0807bfdc4588ae108a2b108ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 23 Jun 2017 13:32:25 +0200 Subject: macOS: Work around buildup of NSDisplayCycle objects during rapid painting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-60012 Change-Id: Id5291f768a4b9d8d9c77804cb697e0c9fb151012 Reviewed-by: Timur Pocheptsov Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnsview.mm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 66c3b6fad4..80c8bfc48b 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -381,6 +381,14 @@ static bool _q_dontOverrideCtrlLMB = false; m_backingStore = backingStore; m_backingStoreOffset = offset * m_backingStore->paintDevice()->devicePixelRatio(); + + // Prevent buildup of NSDisplayCycle objects during setNeedsDisplayInRect, which + // would normally be released as part of the root runloop's autorelease pool, but + // can be kept alive during repeated painting which starve the root runloop. + // FIXME: Move this to the event dispatcher, to cover more cases of starvation. + // FIXME: Figure out if there's a way to detect and/or prevent runloop starvation. + QMacAutoReleasePool pool; + for (const QRect &rect : region) [self setNeedsDisplayInRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())]; } -- cgit v1.2.3