Hi Bruce,

The movies plugins (ffmpeg/quicktime/xine) create ImageStream objects on the
heap for reading the movies and start their own threads.  They pass this
ImageStream back via a ReadResult where a ref_ptr<> holds it, then the
calling code takes charge of this either via the ReadResult or via the raw C
pointer as in the case of the convenience function readImageFile(), with the
later the ImageStream is taken form the ref_ptr<> in the ReadResult in a way
that resets the ref counting to 0 without deleting it.

When using the readImageFile its the callers responsibility to properly
manage it either by keeping a local ref_ptr<> for it, or passing it on to
the scene graph.  As for nasty situation... we'll worse that will happen
will be a memory leak if you are a sloppy programmer.   Personally I make
assumptions that people who use the OSG are grown up enough to handle a
pointer correctly and not have to nanny them with every little thing that
they can do with the OSG.

Robert.



On Mon, Mar 8, 2010 at 2:44 AM, Bruce Wheaton <[email protected]> wrote:

> I had a bit of trouble tracking down where the ImageStream object is
> handled, and I think I've worked it out, but it's quite odd, even for a
> demo.
>
> As far as I can tell, an Image is created from the provided file name and
> held in a pointer. That image is cast to an imagestream for some housework.
> A texture is created and the image is set as it's source - this is all a
> pointer, as far as I can tell, not the refPtr I expected to see.
>
> Then, the main thread seems to forget about the image/s, and moves on. It
> then goes into a visitor, which finds any images and makes a ref pointer
> list to them. Is that about right? So there's a ref pointer and a raw
> pointer floating around at once? And for a while, only a pointer? Isn't that
> a pretty nasty situation? Am I missing some C++ kung-fu to make refPtrs in
> the texture or earlier?
>
> Is there an example with a 'better' management of image/stream objects?
>
> Regards,
>
> Bruce Wheaton
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to