[libcamera-devel] [PATCH] qcam: Don't crash if camera can't be opened
Kieran Bingham
kieran.bingham at ideasonboard.com
Mon Apr 27 11:35:27 CEST 2020
Hi Laurent,
On 26/04/2020 23:31, Laurent Pinchart 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>
> ---
> 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;
> + }
Ah indeed, I see otherwise it would start the stream on the Checked action.
I wonder if we fail to start the first camera we shouldn't stay running
(displaying our invalid stream icon), rather than quit()ing. But that's
a separate patch, and would also require changes in
MainWindow::switchCamera().
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>
> startStopAction_->setChecked(true);
> }
>
--
Regards
--
Kieran
More information about the libcamera-devel
mailing list