[vtkusers] vtkSeedWidget bug FIXED!

Bill Lorensen bill.lorensen at gmail.com
Fri Mar 5 14:04:49 EST 2010


Nice catch. I see you submitted a bug. That's great. I'll try your fix
and submit it.

Thanks,

Bill


On Fri, Mar 5, 2010 at 3:45 AM, AGPX <agpxnet at yahoo.it> wrote:
> 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
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list