<div dir="ltr">The way I'm doing things is just to remove the actors from the renderer.<div>Since I'm sure my program doesn't hold any other reference, I do trust that the vtkSmartPointer is doing its job.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 25, 2016 at 5:51 PM, Weiguang guan <span dir="ltr"><<a href="mailto:guanw@rhpcs.mcmaster.ca" target="_blank">guanw@rhpcs.mcmaster.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
In my program (C++), a user can create/remove an object (cone, cylinder, ...) or a widget (vtkBoxWidget, ...). What's the right way of doing so without causing memory leaking or trashing?<br>
<br>
In "Examples/Tutorial/Step6/Cxx/Cone6.cxx", I see the last section of code doing clean-up at the end as follows:<br>
170 cone->Delete();<br>
171 coneMapper->Delete();<br>
172 coneActor->Delete();<br>
173 callback->Delete();<br>
174 boxWidget->Delete();<br>
175 ren1->Delete();<br>
176 renWin->Delete();<br>
177 iren->Delete();<br>
178 style->Delete();<br>
when it exits.<br>
<br>
Lines 170-172 won't delete coneActor because ren1 still use it 99 ren1->AddActor( coneActor ). This example works fine as it delete ren1, renWin, and iren as well at exit point. Shall I do<br>
ren1-RemoveActor(coneActor) in addtion to coneActor->Delete()? I just want to "undo" the creation as if cone had never been created.<br>
<br>
How about the widget boxWidget? It may be trickier. In addition to boxWidget->Delete(), do I need to do something like<br>
boxWidget->SetInteractor(NULL);<br>
boxWidget->UnRegister(iren);<br>
?<br>
<br>
Weiguang<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Thales Luis Rodrigues Sabino</div><div><br></div><div>PhD Student at <a href="http://www.ufjf.br/pgmc/" target="_blank">PGMC-UFJF</a></div><div><a href="http://lattes.cnpq.br/0601030410417146" target="_blank">Lattes</a> | <a href="https://br.linkedin.com/in/tluisrs" target="_blank">LinkedIn</a> | <a href="https://www.researchgate.net/profile/Thales_Luis_Sabino" target="_blank">ResearchGate</a></div></div></div></div></div>
</div>