From 529704d1abb63de567b085edc7c561792e34dea8 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 25 Jan 2019 17:40:18 +0100 Subject: libcamera: pipeline: Refuse to substitute camera data Once a pipeline-specific data has been associated with a camera, refuse to update it in order to avoid invalidating the previously set reference, which might still be owned by the caller. Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline_handler.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/libcamera/pipeline_handler.cpp') diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index dc55f8fa..1c864079 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -212,19 +212,20 @@ CameraData *PipelineHandler::cameraData(const Camera *camera) * information with \a camera. Ownership of \a data is transferred to * the PipelineHandler. * - * If pipeline-specific data has already been associated with the camera by a - * previous call to this method, is it replaced by \a data and the previous data - * are deleted, rendering all references to them invalid. + * Pipeline-specific data can only be set once. Any attempt to call + * this method after the first one with the same camera won't change + * the pipeline-specific data. * * The data can be retrieved by pipeline handlers using the cameraData() method. */ void PipelineHandler::setCameraData(const Camera *camera, std::unique_ptr data) { - if (cameraData_.count(camera)) - LOG(Pipeline, Debug) - << "Replacing data associated with " - << camera->name(); + if (cameraData_.find(camera) != cameraData_.end()) { + LOG(Pipeline, Error) + << "Replacing data associated with a camera is forbidden"; + return; + } cameraData_[camera] = std::move(data); } -- cgit v1.2.1