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>
This commit is contained in:
Umang Jain 2020-07-31 18:14:20 +00:00 committed by Laurent Pinchart
parent 9c5f821396
commit f2df5abe5d
3 changed files with 8 additions and 3 deletions

View file

@ -13,6 +13,7 @@
#include <string>
#include <libcamera/controls.h>
#include <libcamera/object.h>
#include <libcamera/request.h>
#include <libcamera/signal.h>
#include <libcamera/stream.h>
@ -66,7 +67,7 @@ protected:
std::vector<StreamConfiguration> config_;
};
class Camera final : public std::enable_shared_from_this<Camera>
class Camera final : public Object, public std::enable_shared_from_this<Camera>
{
public:
static std::shared_ptr<Camera> create(PipelineHandler *pipe,