[vtk-developers] Bug update : (if anyone is interested)

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Fri Apr 27 07:50:28 EDT 2001

Attached is a cxx file which will cause a crash (I hope).

There appear to be two bugs. One I can fix, the other I'm less sure about.

Bug 1).
When Actor is removed from Renderer, its mapper still has graphics 
resources allocated
If renderwindow is deleted Mapper's "LastWindow" variable is still pointed 
to but is now dead.
Crash occurs in Mapper destructor, when ReleaseGraphicsResources is called
Solution : Add to vtkViewport.cxx :: RemoveProp

Bug 2). See attached file
As above, but now we Actor->SetMapper(NULL) before removing actor from 
renderwindow. Now RemoveProp doesn't call ReleaseGraphicsResources(...) 
because Mapper is NULL. crash occurs in destructor as before
Solution: Probably call ReleaseGraphicsResources when Actor has mapper changed.

Comments please. I'm playing with stuff I am not fully qualified to fix. I 
understand the issues, but the mappers/renderwindows have many more complex 
interactions which you guys at kitware understand better and if we go round 
calling releaseGraphicsResources every ten minutes, performance could get a 
serious kick in the wotsits.

Also bear in mind, I could be completely wrong.



-------------- next part --------------
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkSphereSource.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"

//#include "SaveImage.h"

int main( int argc, char *argv[] )
  char a;
  // create a rendering window and renderer
  vtkRenderer *ren = vtkRenderer::New();

  vtkRenderWindow *renWindow = vtkRenderWindow::New();

  vtkSphereSource *sphere = vtkSphereSource::New();

  vtkDataSetMapper *sphereMapper = vtkDataSetMapper::New();

  vtkActor *sphereActor = vtkActor::New();

  // assign our actor to the renderer

  // draw the resulting scene

  // Now that everything is initialized, Clear the mapper
  // if this line is removed, the bug disappears.
  // WHY ? Because the ReleaseGraphicsResources doesn't get called
  // when the mapper is cleared, and instead it happens in the destructor
  // solution appears to be to add ReleaseGraphicsResources when
  // actor is unhitched from window
  // in vtkViewPort
  // RemoveProp - : Add ReleaseGraphicsResources(...)
  // also actor->SetMapper(...) should call same?

  // loop until key is pressed
  cout << "Press any key followed by <Enter> to exit>> ";
  cin >> a;


  // Now remove the actor from the renderer

  // Now delete the window and renderer

  // Now delete the actor

  // And now the mapper should have a dangling pointer which will cause a crash


More information about the vtk-developers mailing list