[libcamera-devel] [PATCH] qcam: Don't crash if camera can't be opened

Umang Jain email at uajain.com
Mon Apr 27 13:45:20 CEST 2020


Hi,

On Mon, Apr 27, 2020 at 01:31, Laurent Pinchart 
<laurent.pinchart at ideasonboard.com> wrote:
> 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.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com 
> <mailto:laurent.pinchart at ideasonboard.com>>
> ---
>  src/qcam/main_window.cpp | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index cf39ed7aceca..ed0cad417d62 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);
>  }


This also fixes a segfault when the "Select Camera" dialog is closed[x] 
to exit QCam (i.e. no camera is selected).
Thanks.

Reviewed-by: Umang Jain <email at uajain.com>

> --
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org 
> <mailto:libcamera-devel at lists.libcamera.org>
> <https://u15657259.ct.sendgrid.net/ls/click?upn=8H1KCc2bev8KdIveckpOEBeWjI3THEr-2F8W-2FrEpvXj1fUaD8nZSgfyCwFn-2BKX4QPmzP3yuD-2FqUTQ0p4eTt76rvA-3D-3D4tnk_C3wFy2Q4UgRsRLDAYieRZ5Z3EhAWyy0-2FkOzyYc6FPc1dn6ROcAJqKXb9hjP566uP1e5M4N-2F8GT19qzOCb8CuCYu-2FO2uDnfNqUr41Orvj3-2BchlJd76X1SPt3ovYqUp-2F9-2FaDOIC-2FhfNoe6Lbb7ZHsHnUFZTTRE4YObL2n8JsyeH-2BJhJmPjgWxHeMJSRMHDqt3rsxfHS2ZDJeZrSjIv1MKzTldqRXCzan6wC6uBls-2FdrTYEYuvB7fI1SBSh9mIh4SdXE-2FbIXDpIvLEsqVXetrbnNQ-3D-3D>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20200427/05d8f8e4/attachment.htm>


More information about the libcamera-devel mailing list