From f2df5abe5db9da36d4f07192a037acbcda2dee02 Mon Sep 17 00:00:00 2001 From: Umang Jain Date: Fri, 31 Jul 2020 18:14:20 +0000 Subject: 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 Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- include/libcamera/camera.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/libcamera/camera.h') diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 4d1a4a9f..7dd23d75 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -66,7 +67,7 @@ protected: std::vector config_; }; -class Camera final : public std::enable_shared_from_this +class Camera final : public Object, public std::enable_shared_from_this { public: static std::shared_ptr create(PipelineHandler *pipe, -- cgit v1.2.1