Cocoa: QNSView - fix memory leak of QContainerLayer

setLayer will increment the reference count, so QContainerLayer is
leaked, as it is not autoreleased.

Pick-to: 6.10
Change-Id: I43cef8bbf9ccb9b849322edfb1e7ab75f5ae9898
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tim Blechmann 2025-06-01 17:14:08 +08:00
parent c8ebe2e5cd
commit e6dfd2e9b0

View File

@ -142,7 +142,7 @@
static const bool containerLayerOptOut = qEnvironmentVariableIsSet("QT_MAC_NO_CONTAINER_LAYER");
if (m_platformWindow->window()->surfaceType() != QSurface::OpenGLSurface && !containerLayerOptOut) {
qCDebug(lcQpaDrawing) << "Wrapping content layer" << layer << "in container layer";
auto *containerLayer = [[QContainerLayer alloc] initWithContentLayer:layer];
auto *containerLayer = [[[QContainerLayer alloc] initWithContentLayer:layer] autorelease];
containerLayer.name = @"Qt container layer";
containerLayer.delegate = self;
layer = containerLayer;