libcamera: request: addBuffer(): Do not destroy fence on failure

Take the unique pointer to the `Fence` object by rvalue reference
so that it is not destroyed if the function returns an error code
and does not take ownership of the unique pointer.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze
2025-02-27 12:10:04 +01:00
parent 49439d6de5
commit 0e096da4b4
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -452,7 +452,9 @@ void Request::reuse(ReuseFlag flags)
*
* When a valid Fence is provided to this function, \a fence is moved to \a
* buffer and this Request will only be queued to the device once the
* fences of all its buffers have been correctly signalled.
* fences of all its buffers have been correctly signalled. Ownership of the
* fence will only be taken in case of success, otherwise the fence will
* be left unmodified.
*
* If the \a fence associated with \a buffer isn't signalled, the request will
* fail after a timeout. The buffer will still contain the fence, which
@@ -468,7 +470,7 @@ void Request::reuse(ReuseFlag flags)
* \retval -EINVAL The buffer does not reference a valid Stream
*/
int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,
std::unique_ptr<Fence> fence)
std::unique_ptr<Fence> &&fence)
{
if (!stream) {
LOG(Request, Error) << "Invalid stream reference";