[osg-users] Error: 'Debug Assertion Failure!'
Gordon Tomlinson
gordon at gordon-tomlinson.com
Thu Jan 3 00:05:12 PST 2008
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 : gordon at GordonTomlinson.com
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: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080103/08946260/attachment.html
More information about the osg-users
mailing list