The assertion is doing its job and telling you the issue a bad index ( also
might be good to tell us which line of code is doing this, I'm assuming
which one here ;)  )
 
Will you always have 2 or more children ? as your code is removing child
number 2 every time(indices are zero based), so if you have 2 children the
second time around your code would fail due to there only being 1 child
after one had been removed the first time etc...
 
 
root->removeChild(root->getChildIndex((*ponto_itr)), 1);
 
Should the 1 be 0?  or the last child ? if the last then you need to do an
int idx = root->getNumChildren() -1; and use that idx rather than 1 or 0
 
also for me I would be do something like the following, checking for valid
pointers etc...
 
osg::Group* root = (*ponto_itr)->getParent(0); 
 
if( root && root->getChildIndex((*ponto_itr)), 0))
   root->removeChild(root->getChildIndex((*ponto_itr)), 0);
 

__________________________________________________________
Gordon Tomlinson 

Email   : [EMAIL PROTECTED]
Website : www.vis-sim.com www.gordontomlinson.com 


__________________________________________________________

"Self defence is not a function of learning tricks 
but is a function of how quickly and intensely one 
can arouse one's instinct for survival" 
-Master Tambo Tetsura 

 

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Renan
Mendes
Sent: 03 January 2008 01:48
To: OSG Mailing List
Subject: [Norton AntiSpam] [osg-users] Error: 'Debug Assertion Failure!'


Hi, everyone.

      When testing my application, an error message appeared saying: 'Debug
Assertion Failure' and 'vector subscription out of range'. This error
occured when:

1) I wrote the following code: 

case(osgGA::GUIEventAdapter::KEYDOWN):
            {
                if(!ponto.empty()) // ponto is defined as:
std::vector<Ponto*> ponto; in which Ponto is a class created by me.
                {
                    for(ponto_itr = ponto.begin(); ponto_itr != ponto.end();
ponto_itr++)
                    {
                        if((*ponto_itr)->verifySelection()) // verifies if
the shape associated with an instance of the class Ponto was picked 
                        {
                            switch(ea.getKey())
                            {
                            case(ea.KEY_Delete):
                                {
                                    osg::Group* root =
(*ponto_itr)->getParent(0); 
 
root->removeChild(root->getChildIndex((*ponto_itr)), 1);
                                }
                            }
                        }
                    } 
                }


2) AND when I do the following:
      1 - select one point;
      2 - delete it;
      3 - press delete again, having or NOT selected another 'ponto'
(instance of class Ponto) on the screen. 

NOTE: when a drawable from 'ponto' is selected (picked), the 'ponto' is
allocated in the vector.


      Thanks,

          Renan M Z Mendes

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to