macOS: Work around buildup of NSDisplayCycle objects during rapid painting

Task-number: QTBUG-60012
Change-Id: Id5291f768a4b9d8d9c77804cb697e0c9fb151012
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Tor Arne Vestbø 2017-06-23 13:32:25 +02:00
parent 460a591a93
commit 3851a8ff20
1 changed files with 8 additions and 0 deletions

View File

@ -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())];
}