{"id":3551,"url":"https://patchwork.libcamera.org/api/1.1/patches/3551/?format=json","web_url":"https://patchwork.libcamera.org/patch/3551/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200426223126.17943-1-laurent.pinchart@ideasonboard.com>","date":"2020-04-26T22:31:26","name":"[libcamera-devel] qcam: Don't crash if camera can't be opened","commit_ref":"96980e35ae64df51fa6830622e776506e9a4cf42","pull_url":null,"state":"accepted","archived":false,"hash":"f4afe7749f4194ac510d854533cd8b49ee0dd27c","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3551/mbox/","series":[{"id":830,"url":"https://patchwork.libcamera.org/api/1.1/series/830/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=830","date":"2020-04-26T22:31:26","name":"[libcamera-devel] qcam: Don't crash if camera can't be opened","version":1,"mbox":"https://patchwork.libcamera.org/series/830/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3551/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3551/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F6EB603FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Apr 2020 00:31:45 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0E9424F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Apr 2020 00:31:44 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"QMkrUAoy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1587940305;\n\tbh=IU/1UKaPPOxhtAjLrX9XXbJJe7QWeMJftaZuD11jRzg=;\n\th=From:To:Subject:Date:From;\n\tb=QMkrUAoyiEZa+xMMdlveM8WHcxGqpU+5WT/tDdS8l/LwoAUGpPuH3pU7SRSnkmnru\n\tLAHlweixgAc4Kr175TCjO29rRx9kmZz+xQcmivYXWUDCucJQM2uCvtV9RwUjUozAYl\n\tyvJJiWHXK1aPhHbNxXyD3/mkw4GJkSBcO3mfLa3M=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 27 Apr 2020 01:31:26 +0300","Message-Id":"<20200426223126.17943-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.25.3","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] qcam: Don't crash if camera can't be\n\topened","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sun, 26 Apr 2020 22:31:45 -0000"},"content":"If the camera specified on the command line can't be opened, the\nMainWindow constructor still proceeds to check the startStopAction_,\nwhich results in MainWindow::startCapture() being called and trying to\nuse a null camera_ object. Fix this by returning from the constructor as\nsoon as the error is detected.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/qcam/main_window.cpp | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)","diff":"diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex cf39ed7aceca..ed0cad417d62 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -70,8 +70,10 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n \n \t/* Open the camera and start capture. */\n \tret = openCamera();\n-\tif (ret < 0)\n+\tif (ret < 0) {\n \t\tquit();\n+\t\treturn;\n+\t}\n \n \tstartStopAction_->setChecked(true);\n }\n","prefixes":["libcamera-devel"]}