[vtkusers] New crash bug! This time in vtkSeedWidget!

AGPX agpxnet at yahoo.it
Fri Mar 26 08:42:02 EDT 2010


Hi guys'n'gals,

The method DeleteSeed of the class vtkSeedWidget crash:

void vtkSeedWidget::DeleteSeed(int i)
{
  if( this->Seeds->size() <= static_cast< size_t >(i) )
    {
    return;
    }

  vtkSeedRepresentation *rep =
      static_cast<vtkSeedRepresentation*>(this->WidgetRep);
  if (rep)
    {
    rep->RemoveHandle( i );
    }

  vtkSeedListIterator iter = this->Seeds->begin();
  vtkstd::advance(iter,i);
  (*iter)->SetEnabled(0);
  (*iter)->RemoveObservers(vtkCommand::StartInteractionEvent);
  (*iter)->RemoveObservers(vtkCommand::InteractionEvent);
  (*iter)->RemoveObservers(vtkCommand::EndInteractionEvent);
  vtkHandleWidget * w = (*iter);   
  this->Seeds->erase( iter );
  w->Delete();
}

The problem is in the last two lines. You have to FIRST delete the object, then erase the relative iterator. That is you have to swap the last two lines:

  w->Delete();
  this->Seeds->erase( iter );

Please fix it! Thanks.

- AGPX



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100326/7229fafb/attachment.htm>


More information about the vtkusers mailing list