summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_manager.cpp
diff options
context:
space:
mode:
authorUmang Jain <email@uajain.com>2020-07-31 18:14:20 +0000
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-31 23:33:38 +0300
commitf2df5abe5db9da36d4f07192a037acbcda2dee02 (patch)
treecf2dc801600075dc9d3c88fdfaee9bbd2281a8f5 /src/libcamera/camera_manager.cpp
parent9c5f82139689a0133f8c253100762511af2e3a6e (diff)
libcamera: camera: Ensure deletion via deleteLater()
Object::deleteLater() ensures that the deletion of the Object takes place in a thread it is bound to. Deleting the Object in a different thread is a violation according to the libcamera threading model. On hot-unplug of a currently streaming camera, the last reference of Camera when dropped from the application thread (for e.g. QCam's thread), the destructor is then called from this thread. This is not allowed by the libcamera threading model. Camera is meant to be deleted in the thread it is bound to - in this case the CameraManager's thread. 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>
Diffstat (limited to 'src/libcamera/camera_manager.cpp')
-rw-r--r--src/libcamera/camera_manager.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index f60491d2..c45bf33f 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -164,9 +164,13 @@ void CameraManager::Private::cleanup()
/*
* Release all references to cameras to ensure they all get destroyed
- * before the device enumerator deletes the media devices.
+ * before the device enumerator deletes the media devices. Cameras are
+ * destroyed via Object::deleteLater() API, hence we need to explicitly
+ * process deletion requests from the thread's message queue as the event
+ * loop is not in action here.
*/
cameras_.clear();
+ dispatchMessages(Message::Type::DeferredDelete);
enumerator_.reset(nullptr);
}