[vtkusers] object existence

Barth, Sebastian sebastian.barth at iosb.fraunhofer.de
Wed Jul 7 03:50:24 EDT 2010


Hello,

I don't know if it is possible. You can call GetReferenceCount() but this will cause an application crash if the objects does not exist.
Anyway, you normally should not come into the situation where you have to check, if a reference you hold is still existing.

I'm also still confused by the garbage collection of VTK.

vtkObjectBase::New() will create and return a new instance of vtkObject with a reference count of 1 (vtk assumes that you are holding a reference to this object in the current scope).

If you now assign this object to another vtkObjectBase, its reference count will be increased by 1 to 2.

If you now call Delete() or Unregister(int) (I still don't know for what the parameter is used for) the reference count is decreased by 1 but the object is NOT deleted since its reference count is still higher than 0 (it's 1).

I could not find a difference between Delete() and Unregister(int) apart of the parameter that seems not to be used (or I am too stupid to read the code).

Register() increases the reference count of an object.
Normally, all set, add, append, and remove methods in VTK should use these functions by default.

Hope this helps.
Correct me if I am wrong.

Sebastian Barth

Von: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] Im Auftrag von Haider Syed
Gesendet: Dienstag, 6. Juli 2010 16:52
An: vtkusers at vtk.org
Betreff: [vtkusers] object existence

Hi,

I have an instance of vtkContourWidget declared, call it cwidget.  I have a delete button for this instance and I need to check if the instance exists or not.  How can I check if cwidget exists or not.  This may have something to do with reference counting but I don't understand this concept fully....



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100707/85755d7b/attachment.htm>


More information about the vtkusers mailing list