From 96980e35ae64df51fa6830622e776506e9a4cf42 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Apr 2020 01:29:04 +0300 Subject: qcam: Don't crash if camera can't be opened If the camera specified on the command line can't be opened, the MainWindow constructor still proceeds to check the startStopAction_, which results in MainWindow::startCapture() being called and trying to use a null camera_ object. Fix this by returning from the constructor as soon as the error is detected. This also fixes a similar crash if the camera selection dialog box is closed without selecting a camera. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain --- src/qcam/main_window.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/qcam') diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index cf39ed7a..ed0cad41 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -70,8 +70,10 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) /* Open the camera and start capture. */ ret = openCamera(); - if (ret < 0) + if (ret < 0) { quit(); + return; + } startStopAction_->setChecked(true); } -- cgit v1.2.1