[libcamera-devel] [PATCH 2/4] libcamera: Make Camera destructor public
Jacopo Mondi
jacopo at jmondi.org
Tue Jan 15 16:57:28 CET 2019
Hi Laurent,
On Tue, Jan 15, 2019 at 05:43:08PM +0200, Laurent Pinchart wrote:
> On Tuesday, 15 January 2019 16:57:54 EET Kieran Bingham wrote:
> > Hi Jacopo,
> >
> > On 15/01/2019 14:07, Jacopo Mondi wrote:
> > > The Camera class destructor is defined as private, but it needs to be
> > > accessed by classes that create Camera instances, such as pipeline
> > > handlers.
> >
> > This seems reasonable to me
>
> Not to me. Do you guys read the documentation ? :-) This isn't how cameras are
> destroyed.
Ah, ups
void Camera::put()
{
if (--ref_ == 0)
delete this;
}
Yes, this calls for shared_ptr<>
>
> > Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> >
> > > Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> > > ---
> > >
> > > include/libcamera/camera.h | 2 +-
> > > src/libcamera/pipeline/vimc.cpp | 2 ++
> > > 2 files changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h
> > > index 9a7579d..d751d2d 100644
> > > --- a/include/libcamera/camera.h
> > > +++ b/include/libcamera/camera.h
> > > @@ -15,13 +15,13 @@ class Camera
> > > {
> > > public:
> > > Camera(const std::string &name);
> > > + virtual ~Camera() { };
> > >
> > > const std::string &name() const;
> > > void get();
> > > void put();
> > >
> > > private:
> > > - virtual ~Camera() { };
> > > int ref_;
> > > std::string name_;
> > > };
> > > diff --git a/src/libcamera/pipeline/vimc.cpp
> > > b/src/libcamera/pipeline/vimc.cpp index 720d9c2..00c544c 100644
> > > --- a/src/libcamera/pipeline/vimc.cpp
> > > +++ b/src/libcamera/pipeline/vimc.cpp
> > > @@ -41,6 +41,8 @@ PipeHandlerVimc::~PipeHandlerVimc()
> > >
> > > if (dev_)
> > > dev_->release();
> > > +
> > > + delete camera_;
> > > }
> > >
> > > unsigned int PipeHandlerVimc::count()
>
> --
> Regards,
>
> Laurent Pinchart
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20190115/8d0a8a7f/attachment-0001.sig>
More information about the libcamera-devel
mailing list