summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@gmail.com>2023-05-01 07:54:06 +1000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-05-26 10:07:34 +0000
commit07b992d3d644abcfb71dd694a3fad6ff4d83dcf3 (patch)
treee8fdefbdb38e2e83a07dc923b5d74b95336554de
parent6859d9f6b9dec9971e86e30ba7b7109ea8c9608d (diff)
wasm: fix switching cameras
Fixes: QTBUG-113263 Change-Id: If2a740b4224e6f618896f23ce28dc2b02aa2d6d1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit da90f218005e9f2acae2bf8cce721b01c1a98598) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/multimedia/wasm/mediacapture/qwasmmediacapturesession.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/plugins/multimedia/wasm/mediacapture/qwasmmediacapturesession.cpp b/src/plugins/multimedia/wasm/mediacapture/qwasmmediacapturesession.cpp
index 4454f24f7..7b06bf61f 100644
--- a/src/plugins/multimedia/wasm/mediacapture/qwasmmediacapturesession.cpp
+++ b/src/plugins/multimedia/wasm/mediacapture/qwasmmediacapturesession.cpp
@@ -25,14 +25,18 @@ QPlatformCamera *QWasmMediaCaptureSession::camera()
void QWasmMediaCaptureSession::setCamera(QPlatformCamera *camera)
{
- if (!camera)
- return;
- QWasmCamera *wasmCamera = static_cast<QWasmCamera *>(camera);
- if (!wasmCamera || m_camera.data() == wasmCamera)
- return;
- m_camera.reset(wasmCamera);
+ if (!camera) {
+ if (m_camera == nullptr)
+ return;
+ m_camera.reset(nullptr);
+ } else {
+ QWasmCamera *wasmCamera = static_cast<QWasmCamera *>(camera);
+ if (m_camera.data() == wasmCamera)
+ return;
+ m_camera.reset(wasmCamera);
+ m_camera->setCaptureSession(this);
+ }
emit cameraChanged();
- m_camera->setCaptureSession(this);
}
QPlatformImageCapture *QWasmMediaCaptureSession::imageCapture()