[libcamera-devel] [PATCH] qcam: Don't crash if camera can't be opened
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon Apr 27 14:28:44 CEST 2020
Hi Umang,
On Mon, Apr 27, 2020 at 11:45:20AM +0000, Umang Jain wrote:
> On Mon, Apr 27, 2020 at 01: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
> > <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).
Good point. I'll add it to the commit message, thanks for reporting it.
> Thanks.
>
> Reviewed-by: Umang Jain <email at uajain.com>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list