From patchwork Fri Aug 22 15:08:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 24182 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6C6C3BEFBE for ; Fri, 22 Aug 2025 15:09:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 75E3B692DF; Fri, 22 Aug 2025 17:09:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nzSjOnw0"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0211D613C3 for ; Fri, 22 Aug 2025 17:08:57 +0200 (CEST) Received: from pb-laptop.local (185.221.141.188.nat.pool.zt.hu [185.221.141.188]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A817A11D5 for ; Fri, 22 Aug 2025 17:07:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755875277; bh=Oyxox+wZFBvI/+EI/1GGruauB+9HQh03q/Utl/U9694=; h=From:To:Subject:Date:From; b=nzSjOnw0O+xzh7+cx4rJudVeiYkzJroH7dN38cLI3KBo9Wkj1Ke4zZD7dr6ZyHQmf Ryz3j5c+aHH7B2VlLbXvbBoRQEFnePAEO9zZmfCfwCcqA59zVD8OYrLzmB+MmQJJL0 +CuiboI/Ju7io0Jp0/tfuWzBCeLAZm448hFkg4Yw= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] apps: qcam: Do nothing if no camera is selected Date: Fri, 22 Aug 2025 17:08:54 +0200 Message-ID: <20250822150854.591964-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- 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 7e3f3da60..96a2d5090 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_);