[vtkusers] RE: User-defined ExitMethod to close an interactive vtk model by breaking threads to vtkRenderWindowInteractor and vtkRenderWindow gives Segmentation Fault

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Wed Nov 21 15:51:19 EST 2001


>>>>> "AU" == Anwar Upal <upal at me.queensu.ca> writes:

    AU> Dear Mr Prabhu Ramachandran & Other Users: If I use a static
    AU> member function instead of a static_cast, gdb gives the

Yes, clearly a static member func will not work.

    AU> If I use a static_cast, then the program compiles
    AU> successfully.  And the gdb debugger gives the following error
    AU> at runtime when I press "q" to close the render window:

// set the user-defined C-style ExitMethod as the new exit method
iren->SetExitMethod (ExitMethod,NULL);

void ExitMethod(void *arg)
{
  static_cast<carpus*>(arg)->MemberExitMethod(arg);
};

Isnt this obviously wrong?  You are casting a NULL into a carpus*.
This will most definitely cause you lots of grief.  Shouldn;t you
instead do 

iren->SetExitMethod (ExitMethod, this);

???


prabhu



More information about the vtkusers mailing list