summaryrefslogtreecommitdiff
path: root/src/plugins/avfoundation
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@digia.com>2014-03-04 14:11:01 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-04 17:53:39 +0100
commit1286300a4c847e7fb08410ee6052ba2dcc7b7de2 (patch)
tree360fd82d9d71363a11421cc66de6d7d485582f26 /src/plugins/avfoundation
parent9a55f5ce5746fa1df6daa62a7111cb2d5ff5138d (diff)
downloadqtmultimedia-1286300a4c847e7fb08410ee6052ba2dcc7b7de2.tar.gz
AVFoundation: Cleanup AVCaptureSession with proper reference counting
The reference counting was not being done for AVCaptureSession so it was being destroyed before we got a chance to properly clean it up (which lead to crashes). We also make sure to remove any observers from AVCaptureSession now before destroying it. Task-number: QTBUG-37109 Task-number: QTBUG-29955 Change-Id: Ia9b49ad1eab01b4f7424e2a1c699d903cd9bf902 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
Diffstat (limited to 'src/plugins/avfoundation')
-rw-r--r--src/plugins/avfoundation/camera/avfcamerasession.mm17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm
index 042855aa4..a72ef5041 100644
--- a/src/plugins/avfoundation/camera/avfcamerasession.mm
+++ b/src/plugins/avfoundation/camera/avfcamerasession.mm
@@ -85,6 +85,7 @@ QMap<QByteArray, AVFCameraInfo> AVFCameraSession::m_cameraInfo;
self->m_session = session;
self->m_captureSession = session->captureSession();
+ [m_captureSession retain];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(processRuntimeError:)
name:AVCaptureSessionRuntimeErrorNotification
@@ -103,6 +104,22 @@ QMap<QByteArray, AVFCameraInfo> AVFCameraSession::m_cameraInfo;
return self;
}
+- (void) dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:AVCaptureSessionRuntimeErrorNotification
+ object:m_captureSession];
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:AVCaptureSessionDidStartRunningNotification
+ object:m_captureSession];
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:AVCaptureSessionDidStopRunningNotification
+ object:m_captureSession];
+ [m_captureSession release];
+ [super dealloc];
+}
- (void) processRuntimeError:(NSNotification *)notification
{