qcam: Fix crash when switching from non existant camera
When switching to different camera we try to release the camera previously used. But if that camera has been unplugged, then its instance would have been destroyed. Accessing it leads to seg fault. Fix by checking camera_ to see if it exists. Bug: https://bugs.libcamera.org/show_bug.cgi?id=147 Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
6225d647b4
commit
5a9fd9a95c
1 changed files with 3 additions and 1 deletions
|
@ -284,7 +284,9 @@ void MainWindow::switchCamera()
|
|||
*/
|
||||
startStopAction_->setChecked(false);
|
||||
|
||||
camera_->release();
|
||||
if (camera_)
|
||||
camera_->release();
|
||||
|
||||
camera_ = cam;
|
||||
|
||||
startStopAction_->setChecked(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue