Since that call to Delete doesn't actually destroy anything (It just decrements the object's reference count from 2 to 1) both are equivalent and it is just a matter of preference. If you put it right there it is less likely to be forgotten later. This happens for example when someone adds a conditional return somewhere before the intended Delete.<br>
<br>David E DeMarle<br>Kitware, Inc.<br>R&D Engineer<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-371-3971 x109<br>
<br><br><div class="gmail_quote">On Tue, Aug 25, 2009 at 1:33 PM, Paul Edwards <span dir="ltr"><<a href="mailto:paul.m.edwards@gmail.com">paul.m.edwards@gmail.com</a>></span> 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>Hi, </div><div><br></div><div>I understand there is a need to call Delete on the object but I don't understand why it is called before the line that uses the object that has just been deleted. I.e. why isn't it:</div>
<div><br></div><div><span style="border-collapse: collapse;"><div class="im"><p style="margin: 0px; text-indent: 0px;">this->GetOutputPortInformation(0)->Set(</p>
<p style="margin: 0px; text-indent: 0px;">vtkDataObject::DATA_EXTENT_TYPE(), <b>newOutput->GetExtentType()</b>);</p><p style="margin: 0px; text-indent: 0px;">
</p></div><p style="margin: 0px; text-indent: 0px;"><b>newOutput->Delete();</b></p><div><b><br></b></div><p></p><p style="margin: 0px; text-indent: 0px;">
instead of:</p><div class="im"><p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;">
</p><p style="margin: 0px; text-indent: 0px;"><b>newOutput->Delete();</b></p><p style="margin: 0px; text-indent: 0px;">
this->GetOutputPortInformation(0)->Set(</p><p style="margin: 0px; text-indent: 0px;">vtkDataObject::DATA_EXTENT_TYPE(), <b>newOutput->GetExtentType()</b>);</p>
<p></p></div></span></div><div><br></div><div>Am I missing something here?</div><div><br></div>Thanks,<div>Paul</div><div><br></div><div><div class="gmail_quote">2009/8/25 Jeff Baumes <span dir="ltr"><<a href="mailto:jeff.baumes@kitware.com" target="_blank">jeff.baumes@kitware.com</a>></span><div>
<div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><br><div class="gmail_quote">On Tue, Aug 25, 2009 at 8:43 AM, Paul Edwards <span dir="ltr"><<a href="mailto:paul.m.edwards@gmail.com" target="_blank">paul.m.edwards@gmail.com</a>></span> 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>Is there a reason why Delete is called before GetExtentType? Or is this a bug? (although it doesn't crash on me....)<br></div></blockquote></div><br></div><span style="border-collapse: collapse;">SetPipelineInformation will cause the information object to increment the reference count of the data object. Thus calling Delete will safely decrement the reference count without yet releasing the memory (this matches the reference created by NewInstance()). This is necessary or else a reference will be floating and the object will never be deleted.</span><div>
<span style="border-collapse: collapse;"><br></span></div><font color="#888888"><div><span style="border-collapse: collapse;">Jeff<br clear="all"></span><br>
</div>
</font></blockquote></div></div></div><br></div>
<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 ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br>