Hi Dirk, hi Thomas

Thanks a lot for the very fast answers!

I completly forgot the ref-counting-system, and of course that's the problem. 
The RefPtrs seem to be interesting, I'll give them a try.

Thanks
/Stefan

PS.:The very friendly and fast responses in this list are great. 

>  Hi Stefan,
>
> On Mon, 2004-11-15 at 11:16, Stefan Hackl wrote:
> > Hi all
> >
> > In my current OSG-project I have to switch between different scenes.
> > 'Cause of convenience-reasons I'm still using the SSM at the moment.
> >
> > To me it seemed logically to use the setRoot()-Method of the
> > SimpleSceneManager to switch between the different scenes. A simple
> > example to illustrate what I tried:
> >
> >         NodePtr scene = makeTorus(.5, 2, 16, 16);
> >  NodePtr scene2 = makeTorus(.5, 2, 16, 16);
> >
> >         mgr = new SimpleSceneManager;
> >         mgr->setWindow(gwin);
> >         mgr->setRoot(scene);
> >  mgr->setRoot(scene2);
> >  mgr->setRoot(scene);
> >         mgr->showAll();
> >
> > But this crashes the application, because as it seems the call to
> > "mgr->setRoot(scene2);" deletes the old Rootnode (= "scene").
> >
> > Is this a known/wanted behaviour?
>
> Yes, that's on purpose. The reference counting to clean up trees that
> are no longer used will delete the first scene, once you set another
> one. If you want to keep it around you will have to explicitly increment
> its reference counter (addRefCP()), or use a RefPtr (if you're using a
> rather current version of OpenSG).
>
> I'd recommend using a RefPtr for any NodePtrs that you keep in your main
> program, as that just automatically solves the problem.
>
> So instead of
>
> NodePtr scene, scene2;
>
> use
>
> #include <OpenSG/OSGRefPtr.h>
>
> RefPtr<NodePtr> scene, scene2;
>
> and it will automatically keep track of the ref count.
>
> Word of warning: as soon as you assign another value to these pointers,
> the old one's refcount is decremented, which might delete them. So to
> temporarily move around values stored in these, you also have to use
> RefPtrs.
>
> Hope it helps
>
>  Dirk
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: InterSystems CACHE
> FREE OODBMS DOWNLOAD - A multidimensional database that combines
> robust object and relational technologies, making it a perfect match
> for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to