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>
This commit is contained in:
committed by
The Qt Project
parent
9a55f5ce57
commit
1286300a4c
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user