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>
This commit is contained in:
parent
a2bdf51ed6
commit
529704d1ab
1 changed files with 8 additions and 7 deletions
|
@ -212,19 +212,20 @@ CameraData *PipelineHandler::cameraData(const Camera *camera)
|
||||||
* information with \a camera. Ownership of \a data is transferred to
|
* information with \a camera. Ownership of \a data is transferred to
|
||||||
* the PipelineHandler.
|
* the PipelineHandler.
|
||||||
*
|
*
|
||||||
* If pipeline-specific data has already been associated with the camera by a
|
* Pipeline-specific data can only be set once. Any attempt to call
|
||||||
* previous call to this method, is it replaced by \a data and the previous data
|
* this method after the first one with the same camera won't change
|
||||||
* are deleted, rendering all references to them invalid.
|
* the pipeline-specific data.
|
||||||
*
|
*
|
||||||
* The data can be retrieved by pipeline handlers using the cameraData() method.
|
* The data can be retrieved by pipeline handlers using the cameraData() method.
|
||||||
*/
|
*/
|
||||||
void PipelineHandler::setCameraData(const Camera *camera,
|
void PipelineHandler::setCameraData(const Camera *camera,
|
||||||
std::unique_ptr<CameraData> data)
|
std::unique_ptr<CameraData> data)
|
||||||
{
|
{
|
||||||
if (cameraData_.count(camera))
|
if (cameraData_.find(camera) != cameraData_.end()) {
|
||||||
LOG(Pipeline, Debug)
|
LOG(Pipeline, Error)
|
||||||
<< "Replacing data associated with "
|
<< "Replacing data associated with a camera is forbidden";
|
||||||
<< camera->name();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cameraData_[camera] = std::move(data);
|
cameraData_[camera] = std::move(data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue