[vtk-developers] should subjects take out references on observers?

Charl P. Botha c.p.botha at its.tudelft.nl
Wed Feb 12 04:30:54 EST 2003


Dear developers,

I expect that there are very good reasons for this, but why don't
vtkObservers (actually vtkSubjectHelpers) take out references to their
observers?  If there aren't, I would propose changing this code.

The Python example I've attached shows how NOT taking out references on
observers can result in breakage.  Start it up, make sure the
renderwindow is active and press 'i' to activate the vtkBoxWidget.  The
application will segfault.

In short, the problem here is that if the user doesn't explicitly
maintain a reference to an observer that has been AddObserver()ed to a
subject, the observer will die (because the subject doesn't take out a
reference on the observer).  As soon as the subject wants to communicate
with the observer (to notify it of an event), the application will
segfault.

Any information in this regard would be appreciated.

Thanks,
Charl

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: observer-breakage.py
Type: text/x-python
Size: 865 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20030212/2dbcefed/attachment-0001.py>


More information about the vtk-developers mailing list