diff options
Diffstat (limited to 'src/libcamera/camera_manager.cpp')
-rw-r--r-- | src/libcamera/camera_manager.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 14410d4d..3eccf20c 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -98,16 +98,14 @@ int CameraManager::start() * all pipelines it can provide. */ while (1) { - PipelineHandler *pipe = factory->create(this); - if (!pipe->match(enumerator_.get())) { - delete pipe; + std::shared_ptr<PipelineHandler> pipe = factory->create(this); + if (!pipe->match(enumerator_.get())) break; - } LOG(Camera, Debug) << "Pipeline handler \"" << factory->name() << "\" matched"; - pipes_.push_back(pipe); + pipes_.push_back(std::move(pipe)); } } @@ -130,10 +128,13 @@ void CameraManager::stop() { /* TODO: unregister hot-plug callback here */ - for (PipelineHandler *pipe : pipes_) - delete pipe; - + /* + * Release all references to cameras and pipeline handlers to ensure + * they all get destroyed before the device enumerator deletes the + * media devices. + */ pipes_.clear(); + cameras_.clear(); enumerator_.reset(nullptr); } |