Hi Fajran, The changes look sensible. I've tested against all the osgwidget* example and everything looks sound.
Change now merged and submitted to svn/trunk and the OSG-2.8 branch. Thanks, Robert. On Tue, May 12, 2009 at 8:31 AM, Fajran Iman Rusadi <[email protected]> wrote: > Dear all, > > I've been dealing with a problem (probably due to a bug) with > osgWidget. If I try to remove Window(s) from WindowManager not in the > reverse order as I insert them, I'll get a segmentation fault. My > debugger says the problem is in file WindowManager.cpp line 431. > > for(Iterator w = begin(); w != end(); w++) { > Window* win = w->get(); > > win->_zRange = zRange; > > win->update(); > } > > The value of win is NULL there. So the next _zRange assignment will > cause an error. > > After I investigated further, seems WindowManager tries to assign an > _index to Window. This index should corresponds with the index in the > Group's _children. The problem arises when I delete any Window but the > last one, because the Window's _index is disrupted since I found no > _index rearrangement (cmiiw). > > I found at least two functions in WindowManager that use this _index: > childRemoved() and resizeAllWindows(). The first one gets an index > (that should be the index in Group's _children) but uses it for > comparison with the incorrect Window's _index. The second function > uses the Window's _index to call Switch's getValue() which then use it > to get a value from its _values. There are also some other functions > in Window class that use this _index value. > > For the project that I'm working on, I'm using OpenSceneGraph 2.8.0. I > also have checked the latest code in the svn repo, but no changes > there since 2.8.0. > > I have made a simple patch to (hopefully) fix the problem. I use the > latest code from subversion (trunk) as a base. What I did was > rearrange all Window's _index when a node is inserted and removed. > When a node is inserted, I simply increment the _index of Window(s) > that have _index larger than or equal the index of the new node (line > 235-238). When some nodes are removed, I do the opposite. I decrement > the Window's _index by the number of nodes that are deleted (line > 270-273). > > I have tested this modification (using OSG 2.8.0 though) with my > program and now the program seems work fine. No error occurred again. > > any comments? > > > regards, > > -- > Fajran Iman Rusadi- > http://fajran.web.id y!m: fajran > > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > > _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
