Hi Lilinx,

Have a osg::ref_ptr<osg::Object>
Registry::getRefFromObjectCache(std::sring&) method is a reasonable
request, now added and checked into svn/trunk.  I also added a
getRefFromArchiveCache() as well.

For older versions of the OSG you can simply use a ref_ptr<Object> in
your own code rather than a C pointer.  This still leaves potential
for an object to go out of scope while being passed back, but this
condition will be a very small window that is unlikely to trip apps up
too readily.

Robert.

On Fri, May 6, 2011 at 3:08 PM, xll <[email protected]> wrote:
>
>  HI,all
>
>        When writing a osgDB::ReadFileCallback, We need know if there was
> someobject existed in the Registry's object cache  on sometime.
> Usualy, We call osgDB::Registry::instance()->getFromObjectCache to do this.
> Example:
>            osg::Object * obj =
> osgDB::Registry::instance()->getFromObjectCache ();
>            if(obj)
> {
>               doSomething();
> }
> else
> {
>               doOtherthing();
> }
>
> When using this in multithread  environment , it is not thread safe: obj
> maybe be deleted before getFromObjectCache return.
>
> So ,  Do We need add a function  osg::ref<Ojbect>
> getRefFromObjectCache(const std::string& fileName )  for osgDB::Registry?
>
>
> Thank you!
> Cheers,
>
> lilinx
>
> ---------------------------------------
> 卡巴斯基,价值非凡的安全保护
>
> _______________________________________________
> 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