<div dir="ltr">Thanks David. <div>It seems that I must ensure that VTK is only ever accessed from the main GUI thread. </div><div>If I find this really difficult then I am going to have to pass all VTK access through some singleton object that "gets ownership of VTK", which will be rather foul!</div>
<div>Many thanks again for the advice, it's going to give me a real headache making a scalable program, but at least I know I'm not going crazy.</div><div>Richard</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On 24 March 2014 11:56, David Cole <span dir="ltr"><<a href="mailto:dlrdave@aol.com" target="_blank">dlrdave@aol.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Unless somebody else replies with better advice, this still stands, to the best of my knowledge:<br>
<br>
<a href="http://vtk.1045678.n5.nabble.com/vtkRenderer-AddActor-tt5721931.html#a5721932" target="_blank">http://vtk.1045678.n5.nabble.<u></u>com/vtkRenderer-AddActor-<u></u>tt5721931.html#a5721932</a><br>
<br>
("VTK is not easily usable from multiple threads. So, in general, you should restrict access to VTK objects to a single thread in your app, or use mutexes to guarantee that only one thread at a time has access to VTK objects. And, if you have to pick a thread to restrict the access to, use the same one that’s doing all the GUI stuff -- VTK rendering has to run in the GUI thread anyhow.")<br>
<br>
The "singleton garbage collection mechanism" you mention is not vtkSmartPointer-specific: if you don't use smart pointer, then you need to call "Delete" manually.... And it is the calls to Delete and/or UnRegister which cause the garbage collection to kick in.<br>
<br>
Any VTK method call which has any possibility of modifying any VTK state, or which renders, or which might create or delete other VTK objects, *must* be called from the main gui thread, or accessed through a locking mechanism like a mutex in order to be safe.<br>
<br>
It's ironic, because VTK filters themselves actually use threads in some cases to achieve speed ups... but it is still very much unusable for client programs to create and use VTK objects from multiple threads themselves.<br>
<br>
If something has changed in the last 2 years that I'm not aware of with respect to using VTK objects from multiple threads, I do expect somebody will chime in here and correct me if I'm wrong.<br>
<br>
<br>
Good luck,<br>
David C.<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif">Richard Whitehead </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">–</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> Senior Imaging Engineer</span></p>
<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">Michelson Diagnostics Ltd</span></b></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">
<b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">M:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> +44 (0)7905 955276 </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">T:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> +44 (0)20 8308 1695</span></p>
<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">E: </span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(0,176,240)"><a href="mailto:richard.whitehead@vivosight.com" style="color:rgb(17,85,204)" target="_blank"><span style="color:rgb(0,176,240)">richard.whitehead@vivosight.com</span></a></span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">W:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> </span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(0,176,240)"><a href="http://www.vivosight.com/" style="color:rgb(17,85,204)" target="_blank"><span style="color:rgb(0,176,240)">www.vivosight.com</span></a></span></p>
<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><br></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><a href="http://www.vivosight.com/" target="_blank"><span style="color:windowtext;text-decoration:none"><img src="https://sites.google.com/a/vivosight.com/logo/_/rsrc/1361922206747/home/VivoSight.png" border="0"></span></a></p>
<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><br></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">
<span style="font-size:7.5pt;font-family:Arial,sans-serif;color:gray">Michelson Diagnostics Ltd, 1 Grays Farm Production Village, Grays Farm Road, Orpington, Kent BR5 3BD, UK</span></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">
<span style="font-size:7.5pt;font-family:Arial,sans-serif;color:gray">Registered Office: 3 Shearwater, Maidstone, ME16 0DW. Registered in England No. 5732681</span></p></div>
</div>