it's a osg::Program*. The thing is, after the call to removeAttribute(), the osg::Program* is still valid. The object has not been deleted, and the pointer is certainly not null. I checked. Unless something inside the osg::Program structure has been screwed with.
I don't see how ref_ptrs are necessary in that case. I understand why they can be practical, like boost's shared_ptr, but hardly necessary all the time. Their main use is to have objects automatically deleted when the ref count hit 0, so you don't have to destro them manually, right? Then, in my case, I certainly don't explicitely destroy the osg::program, and in the source code for StateSet, the pointer is removed form a std::vector<StateAttribute>, which I don't think implies the destruction of the object referred to by the pointer. On Wed, Aug 27, 2008 at 9:07 PM, Gordon Tomlinson <[EMAIL PROTECTED]> wrote: > > I would guess it is a reference count issue if you want to add and remove > and keep a reference counted object then you could call ::ref() on the > object when you create it or use the preferred method of using a variable an > osg::ref_ptr<object> to preserve the scope of the object > > __________________________________________________________ > Gordon Tomlinson > > [EMAIL PROTECTED] > IM: [EMAIL PROTECTED] > www.vis-sim.com www.gordontomlinson.com > __________________________________________________________ > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Louis > Bouchard > Sent: Wednesday, August 27, 2008 5:52 PM > To: [email protected] > Subject: [osg-users] Fwd: Strange stateset / shader problem > > Hi, > > since we cannot turn off a shader program like this: > > setAttributeAndModes(shaderprogram, osg::StateAttribute::OFF) > > .. I tried the suggested method from this post > (http://www.mail-archive.com/[EMAIL PROTECTED]/msg08493.html), > and I simply removeAttribute(...) the shader from the stateset. This > part works quite well. > > However, if I want to turn it back on again, > setAttributeAndModes(shaderprogram, osg::StateAttribute::ON) produces > a segmentation fault. I have no idea why. The shaderprogram pointer > is still valid. I ran this through gdb and it was unhelpful. > > any ideas? > > thanks, > > Louis Bouchard > _______________________________________________ > 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 > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

