From 330a92636d0b88198a9f35809bf09d6d358be2bc Mon Sep 17 00:00:00 2001 From: Matthias Nagel Date: Sat, 3 Oct 2020 14:26:15 +0200 Subject: [PATCH] Fixed qrOutput reference so cleanup works now --- Sources/CameraManager.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sources/CameraManager.swift b/Sources/CameraManager.swift index a568cea..ee87ace 100644 --- a/Sources/CameraManager.swift +++ b/Sources/CameraManager.swift @@ -799,10 +799,15 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest guard let captureSession = self.captureSession else { return } - let output = AVCaptureMetadataOutput() + qrOutput = AVCaptureMetadataOutput() - guard captureSession.canAddOutput(output) - else { return } + guard let output = qrOutput else { + return + } + + guard captureSession.canAddOutput(output) else { + return + } qrCodeDetectionHandler = handler captureSession.addOutput(output) @@ -832,7 +837,7 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest /** The stored meta data output; used to detect QR codes. */ - private var qrOutput: AVCaptureOutput? + private var qrOutput: AVCaptureMetadataOutput? /** Check if the device rotation is locked