diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2019-01-25 17:40:18 +0100 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2019-01-26 16:32:52 +0100 |
commit | 529704d1abb63de567b085edc7c561792e34dea8 (patch) | |
tree | 2d7f64a9e3e98998a9096f77a6b3f6daf3bba2e8 | |
parent | a2bdf51ed6088850be9cc151b96eabd7d391be73 (diff) |
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 <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r-- | src/libcamera/pipeline_handler.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
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<CameraData> 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); } |