macOS: Add a few more local autorelease pools to QCocoaGLContext

Prevents buildup of autoreleased NSViews (drawables) in the outer pool
of the main runloop, which may not drain as often as we wish.

Change-Id: Ifcf7317c50ec243e0d957bf4a19aab8bf34d5dd6
Fixes: QTBUG-84762
Pick-to: 5.15 5.12
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2020-06-08 23:03:36 +02:00
parent 8cccf0a76b
commit 15456efa20

View File

@ -357,6 +357,8 @@ QCocoaGLContext::~QCocoaGLContext()
bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
{ {
QMacAutoReleasePool pool;
qCDebug(lcQpaOpenGLContext) << "Making" << this << "current" qCDebug(lcQpaOpenGLContext) << "Making" << this << "current"
<< "in" << QThread::currentThread() << "for" << surface; << "in" << QThread::currentThread() << "for" << surface;
@ -489,6 +491,8 @@ void QCocoaGLContext::update()
void QCocoaGLContext::swapBuffers(QPlatformSurface *surface) void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
{ {
QMacAutoReleasePool pool;
qCDebug(lcQpaOpenGLContext) << "Swapping" << m_context qCDebug(lcQpaOpenGLContext) << "Swapping" << m_context
<< "in" << QThread::currentThread() << "to" << surface; << "in" << QThread::currentThread() << "to" << surface;
@ -522,6 +526,8 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
void QCocoaGLContext::doneCurrent() void QCocoaGLContext::doneCurrent()
{ {
QMacAutoReleasePool pool;
qCDebug(lcQpaOpenGLContext) << "Clearing current context" qCDebug(lcQpaOpenGLContext) << "Clearing current context"
<< [NSOpenGLContext currentContext] << "in" << QThread::currentThread(); << [NSOpenGLContext currentContext] << "in" << QThread::currentThread();