<div dir="ltr">I'd rather see at the top of the method<div><br></div><div style>if(this == <span style="font-family:arial,sans-serif;font-size:13px">polyData) return;</span></div></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Wed, Jul 3, 2013 at 5:04 AM, xabivtk <span dir="ltr"><<a href="mailto:xabivtk@gmail.com" target="_blank">xabivtk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
I have a crash when calling ShallowCopy on a vtkPolyData when the polydata<br>
passed as argument is the one that calls the method :<br>
data->ShallowCopy(data)<br>
no question that this call is useless...<br>
but looking into the implementation, there is a comment that says : "I do<br>
not know if this is correct but." for the code that deals with the cells and<br>
links arrays, and this is the place where the crash occurs:<br>
<br>
if (this->Cells)<br>
{<br>
this->Cells->UnRegister(this);<br>
}<br>
this->Cells = polyData->Cells;<br>
if (this->Cells)<br>
{<br>
this->Cells->Register(this);<br>
}<br>
<br>
the call to this->Cells->UnRegister(this) makes the polyData->Cells to be<br>
destroyed, so this->Cells->Register(this) will crash.<br>
<br>
I think a check should be added in the same way as in SetLines, SetPolys,<br>
etc... to verify that the input pointer is not the same as the local one:<br>
<br>
if(polyData->Cells != this->Cells)<br>
{<br>
if (this->Cells)<br>
{<br>
this->Cells->UnRegister(this);<br>
}<br>
this->Cells = polyData->Cells;<br>
if (this->Cells)<br>
{<br>
this->Cells->Register(this);<br>
}<br>
...<br>
}<br>
<br>
Any comments on that?<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/missing-check-in-vtkPolyData-ShallowCopy-tp5721741.html" target="_blank">http://vtk.1045678.n5.nabble.com/missing-check-in-vtkPolyData-ShallowCopy-tp5721741.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<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>
</blockquote></div><br></div>