<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div>Hi,<br><br>I wrote a test function that reproduces a crash with calling SetOutput(NULL) on a vtkStructuredPointsReader.<br>I'm using vtk 5.1.0 on Windows XP (by the way, I did not see a vtk version history, I wanted to check if my problem was solved in the latest version).<br><br>The program crashes with the message 'Access violation reading location 0x037ee000'.<br><br>The test function tries to detach the output from the reader. <br>By now, I know a better way to detach an output by using the ShallowCopy function. Still, I would like to know if I'm doing something wrong, or if this is a bug in vtk.<br><br> #include "vtkStructuredPoints.h"<br> #include "vtkStructuredPointsReader.h"<br><br> void
TestToReproduceCrashWithVtkImageReader()<br> {<br> vtkStructuredPointsReader* reader = vtkStructuredPointsReader::New();<br> reader->SetFileName("ironProt.vtk");<br> reader->Update();<br> vtkStructuredPoints* image = reader->GetOutput();<br> image->Register(NULL);<br> reader->SetOutput(NULL); // This line seems to cause problems<br> reader->Delete();<br><br> int imageSize = image->GetNumberOfPoints() * image->GetScalarSize();<br> unsigned char* buffer = new unsigned char[imageSize];<br> <br> // The crash occurs in
this line!<br> memcpy(buffer, image->GetScalarPointer(), imageSize);<br> }<br><br>Note that the test does not crash if I comment out the call to SetOutput(NULL).<br>Thanks!<br>Maarten<br><br><br></div></div><br>
</body></html>