From 16cbc826b7915079dc78862041c4f12a7d6ea7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Fri, 22 Aug 2025 17:08:54 +0200 Subject: [PATCH] apps: qcam: Do nothing if no camera is selected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the currently selected camera disappears as reported by the `cameraRemoved` signal, then `MainWindow::camera_` is reset to `nullptr`. In this case, pressing the start/stop button will try to start streaming, leading to a nullptr derefence in `MainWindow::startCapture()` when the configuration is generated for the camera. Fix that by returning from `MainWindow::toggleCapture()` if no camera is set. While this will cause the "checked" status of `startStopAction_` to go out of sync, this should not be an issue because when a new camera is selected, the state is synchronized. Bug: https://bugs.libcamera.org/show_bug.cgi?id=177 Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Signed-off-by: Kieran Bingham --- src/apps/qcam/main_window.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp index 7e3f3da6..96a2d509 100644 --- a/src/apps/qcam/main_window.cpp +++ b/src/apps/qcam/main_window.cpp @@ -333,6 +333,9 @@ int MainWindow::openCamera() void MainWindow::toggleCapture(bool start) { + if (!camera_) + return; + if (start) { startCapture(); startStopAction_->setIcon(iconStop_);