@@ -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,
@@ -464,7 +464,7 @@ std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,
struct Deleter : std::default_delete<Camera> {
void operator()(Camera *camera)
{
- delete camera;
+ camera->deleteLater();
}
};
@@ -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);
}