Skip to content
  • Max Smolens's avatar
    Change picking manager to not own objects associated with pickers · 7a24b326
    Max Smolens authored
    When adding a vtkPicker to the picking manager, a vtkObject can optionally be
    associated with the picker. This commit changes the behavior of
    vtkPickingManager to not own (i.e. increment the reference count) of these
    associated objects. Instead, the object references are held in a raw pointer.
    
    The widget framework is the primary client of the picking manager. The typical
    vtkWidgetRepresentation subclass adds its pickers to the picking manager and
    includes an associated object reference to itself:
    
        pickingManager->AddPicker(picker, this);
    
    When the widget/representation are destroyed, the vtkWidgetRepresentation
    destructor unregisters its pickers:
    
        pickingManager->RemoveObject(this);
    
    However, because the picking manager took ownership of the associated objects,
    the vtkWidgetRepresentation instances and their pickers are not destroyed until
    the vtkPickingManager is destroyed. In particular applications, this could lead
    to a large number of objects referenced only by vtkPickingManager that would
    exist until application exit.
    
    The picking manager test is updated for the use case demonstrated by the widget
    framework.
    7a24b326