Cocoa: QNSView - fix memory leak of QContainerLayer

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

Change-Id: I43cef8bbf9ccb9b849322edfb1e7ab75f5ae9898
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit e6dfd2e9b084bea53bf39c5fa3d70dbc81777218)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tim Blechmann 2025-06-01 17:14:08 +08:00 committed by Qt Cherry-pick Bot
parent 46c82ac228
commit 84a6c4ca6e

@ -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;