qcam: Fix camera reference leak on hot-unplug

If the currently streaming camera is hot-unplugged, a camera reference
was still held by MainWindow::camera_, preventing it to be destructed,
until qcam window is closed. Plug the leak in the hot-unplug handler
itself.

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Umang Jain 2020-07-27 12:32:59 +00:00 committed by Laurent Pinchart
parent e349cb0f8a
commit c8edfe29c1

View file

@ -587,6 +587,8 @@ void MainWindow::processHotplug(HotplugEvent *e)
/* Check if the currently-streaming camera is removed. */ /* Check if the currently-streaming camera is removed. */
if (camera == camera_.get()) { if (camera == camera_.get()) {
toggleCapture(false); toggleCapture(false);
camera_->release();
camera_.reset();
cameraCombo_->setCurrentIndex(0); cameraCombo_->setCurrentIndex(0);
} }