diff options
author | Artem Dyomin <artem.dyomin@qt.io> | 2022-11-25 15:09:14 +0100 |
---|---|---|
committer | Artem Dyomin <artem.dyomin@qt.io> | 2022-11-29 09:49:51 +0000 |
commit | d73cc0bce893b81de3f84c570110c8969b9ee468 (patch) | |
tree | 592ab5b36c78698062ca845cf3e206b1c8cc97b9 /src | |
parent | 5a0b6bee16c9b71589209e6aa18a77c987d27800 (diff) |
Fix ffmpeg camera crash on macOS (double releasing of an object)
The reason for the crash is 'autorelease' and 'release' in the
destructor. In applications, QMacAutoReleasePool releases it 2nd time.
The application crashed after a few camera changes.
So we should use only one approach. The suggestion is to manage
the object manually for both backends in order to make the behavior
more predictable.
The added test checks the case.
Pick-to: 6.4
Change-Id: I80a644acd94ae469a16fd95ba971441c78e7a700
Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/multimedia/darwin/camera/avfcamerarenderer.mm | 4 | ||||
-rw-r--r-- | src/plugins/multimedia/ffmpeg/qavfcamera.mm | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/multimedia/darwin/camera/avfcamerarenderer.mm b/src/plugins/multimedia/darwin/camera/avfcamerarenderer.mm index 620b2a639..35b339ab9 100644 --- a/src/plugins/multimedia/darwin/camera/avfcamerarenderer.mm +++ b/src/plugins/multimedia/darwin/camera/avfcamerarenderer.mm @@ -87,6 +87,8 @@ AVFCameraRenderer::~AVFCameraRenderer() { [m_cameraSession->captureSession() removeOutput:m_videoDataOutput]; [m_viewfinderFramesDelegate release]; + [m_videoDataOutput release]; + if (m_delegateQueue) dispatch_release(m_delegateQueue); #ifdef Q_OS_IOS @@ -123,7 +125,7 @@ void AVFCameraRenderer::configureAVCaptureSession(AVFCameraSession *cameraSessio m_needsHorizontalMirroring = false; - m_videoDataOutput = [[[AVCaptureVideoDataOutput alloc] init] autorelease]; + m_videoDataOutput = [[AVCaptureVideoDataOutput alloc] init]; // Configure video output m_delegateQueue = dispatch_queue_create("vf_queue", nullptr); diff --git a/src/plugins/multimedia/ffmpeg/qavfcamera.mm b/src/plugins/multimedia/ffmpeg/qavfcamera.mm index cb7cfdaec..d6ec94a0e 100644 --- a/src/plugins/multimedia/ffmpeg/qavfcamera.mm +++ b/src/plugins/multimedia/ffmpeg/qavfcamera.mm @@ -220,7 +220,7 @@ void QAVFCamera::updateVideoInput() attachVideoInputDevice(); if (!m_videoDataOutput) { - m_videoDataOutput = [[[AVCaptureVideoDataOutput alloc] init] autorelease]; + m_videoDataOutput = [[AVCaptureVideoDataOutput alloc] init]; // Configure video output m_delegateQueue = dispatch_queue_create("vf_queue", nullptr); |