From cc01f3e5938f1cd38457b0fd4bbbe9b63fe46178 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Wed, 18 Sep 2024 01:19:48 +0100 Subject: [PATCH] fix retain cycle in controller --- DuckDuckGo/NetworkProtectionTunnelController.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/NetworkProtectionTunnelController.swift b/DuckDuckGo/NetworkProtectionTunnelController.swift index fe6e1620ee..c7b8ebee6d 100644 --- a/DuckDuckGo/NetworkProtectionTunnelController.swift +++ b/DuckDuckGo/NetworkProtectionTunnelController.swift @@ -322,7 +322,8 @@ final class NetworkProtectionTunnelController: TunnelController, TunnelSessionPr private func subscribeToConfigurationChanges() { notificationCenter.publisher(for: .NEVPNConfigurationChange) .receive(on: DispatchQueue.main) - .sink { _ in + .sink { [weak self] _ in + guard let self = self else { return } Task { @MainActor in guard let manager = self.internalManager else { return @@ -346,7 +347,9 @@ final class NetworkProtectionTunnelController: TunnelController, TunnelSessionPr private func subscribeToStatusChanges() { notificationCenter.publisher(for: .NEVPNStatusDidChange) - .sink(receiveValue: handleStatusChange(_:)) + .sink { [weak self] value in + self?.handleStatusChange(value) + } .store(in: &cancellables) }