[vtkusers] vtkSeedWidget bug FIXED!
AGPX
agpxnet at yahoo.it
Fri Mar 5 06:45:00 EST 2010
Ok, look like a bug. Look at the code of the file vtkSeedRepresentation.cxx:
/----------------------------------------------------------------------
void vtkSeedRepresentation::RemoveHandle( int n )
{
// Remove nth handle
if (n == this->ActiveHandle)
{
this->RemoveActiveHandle();
return;
}
if (static_cast<int>(this->Handles->size()) <= n )
{
return;
}
vtkHandleListIterator iter = this->Handles->begin();
vtkstd::advance( iter, n );
this->Handles->erase( iter );
( *iter )->Delete();
}
//----------------------------------------------------------------------
void vtkSeedRepresentation::RemoveActiveHandle()
{
if ( this->Handles->size() < 1 )
{
return;
}
if ( this->ActiveHandle >= 0 && this->ActiveHandle < static_cast<int>(this->Handles->size()) )
{
vtkHandleListIterator iter = this->Handles->begin();
vtkstd::advance( iter, this->ActiveHandle );
this->Handles->erase( iter );
( *iter )->Delete();
this->ActiveHandle = -1;
}
Basically the error are in the following lines:
this->Handles->erase( iter );
( *iter )->Delete();
You have to FIRST delete the object and THEN remove the handle! That is you have to swap the two lines:
( *iter )->Delete();
this->Handles->erase( iter );
Now the example no longer crash (and my application too!).
My two cents!
- AGPX
________________________________
Da: AGPX <agpxnet at yahoo.it>
A: vtk vtk <vtkusers at vtk.org>
Inviato: Ven 5 marzo 2010, 12:19:45
Oggetto: vtkSeedWidget bug?
Hi,
I have compiled the latest version of VTK (from CVS) and the WidgetsCxxTests.exe (debug mode) crashs when you run Test15 (vtkSeedWidget). The error reported is: "list iterator not dereferencable" and the debugger show the line:
( *iter )->Delete();
inside the vtkSeedRepresentation::RemoveHandle method. Basically the DeleteSeed seems doesn't work. I tested it on Microsoft Windows XP Pro with Visual Studio 2008 SP1. Any idea on how to fix? Thanks.
- AGPX
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100305/a4a94ad4/attachment.htm>
More information about the vtkusers
mailing list