[libcamera-devel] [PATCH] qcam: Don't crash if camera can't be opened
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon Apr 27 00:31:26 CEST 2020
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;
+ }
startStopAction_->setChecked(true);
}
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list