apps: qcam: Do nothing if no camera is selected

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 <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze
2025-08-22 17:08:54 +02:00
committed by Kieran Bingham
parent 473e2dc893
commit 16cbc826b7

View File

@@ -333,6 +333,9 @@ int MainWindow::openCamera()
void MainWindow::toggleCapture(bool start)
{
if (!camera_)
return;
if (start) {
startCapture();
startStopAction_->setIcon(iconStop_);