[osg-users] Error: 'Debug Assertion Failure!'

Rafa Gaitan rafa.gaitan at gmail.com
Thu Jan 3 00:14:25 PST 2008


Hi Renan,

Did you clean your ponto vector after removing the child of the parent?. If
you don't
do that, you find that ponto has (for example) one element which value is
NULL. The problem
is that you don't use ref_ptr to save elements inside the vector and OSG
does. So when you
remove the children they are unreferenced and deleted.

Solution: Add a auxiliar vector of iterators to delete, and after your
process, delete all
iterators (ponto.remove(itr)) or something similar.

Hope this helps.
Rafa.


On Jan 3, 2008 2:47 AM, Renan Mendes <renanmzmendes at gmail.com> wrote:

> 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
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>


-- 
Rafael Gaitán Linares
Instituto de Automática e Informática Industrial  http://www.ai2.upv.es
Ciudad Politécnica de la Innovación
Universidad Politécnica de Valencia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080103/7ff38bd1/attachment.html 


More information about the osg-users mailing list