Why are you calling SetOutput(NULL) on a reader object? The reader will clean up after itself when it is deleted, you do not need to call SetOutput(NULL). Did you see this as an example somewhere?<br><br><br><br><div class="gmail_quote">
On Thu, May 22, 2008 at 8:53 AM, Maarten Nieber <<a href="mailto:hallomaarten@yahoo.com">hallomaarten@yahoo.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><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>
</div><br>_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>