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 &lt;<a href="mailto:hallomaarten@yahoo.com">hallomaarten@yahoo.com</a>&gt; 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&#39;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 &#39;Access violation reading location 0x037ee000&#39;.<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&#39;m doing something wrong, or if this is a bug in vtk.<br>
<br>&nbsp;&nbsp;&nbsp; #include &quot;vtkStructuredPoints.h&quot;<br>&nbsp;&nbsp;&nbsp; #include &quot;vtkStructuredPointsReader.h&quot;<br><br>&nbsp;&nbsp;&nbsp; void
 TestToReproduceCrashWithVtkImageReader()<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkStructuredPointsReader* reader = vtkStructuredPointsReader::New();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; reader-&gt;SetFileName(&quot;ironProt.vtk&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; reader-&gt;Update();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkStructuredPoints* image = reader-&gt;GetOutput();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; image-&gt;Register(NULL);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; reader-&gt;SetOutput(NULL); // This line seems to cause problems<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; reader-&gt;Delete();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int imageSize = image-&gt;GetNumberOfPoints() * image-&gt;GetScalarSize();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unsigned char* buffer = new unsigned char[imageSize];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;  // The crash occurs in
 this line!<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; memcpy(buffer, image-&gt;GetScalarPointer(), imageSize);<br>&nbsp;&nbsp;&nbsp; }<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>