Clear IAVolume lists on close

- Lots of cross object references with non-widget IAVolumes. Clear
on widget close as is easy and seems beneficial
This commit is contained in:
John Lewin 2019-05-22 09:21:31 -07:00
parent c8510bdd6d
commit cf3581af02

View file

@ -52,7 +52,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
/// <summary>
/// Contains type to IAVolume mappings
/// </summary>
private Dictionary<Type, List<IInteractionElement>> iavMappings = new Dictionary<Type, List<IInteractionElement>>();
private readonly Dictionary<Type, List<IInteractionElement>> iavMappings = new Dictionary<Type, List<IInteractionElement>>();
/// <summary>
/// Interaction Volume Overrides for the selected scene item
@ -67,7 +67,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public bool DrawOpenGLContent { get; set; } = true;
private List<IInteractionElement> registeredIAVolumes = new List<IInteractionElement>();
private readonly List<IInteractionElement> registeredIAVolumes = new List<IInteractionElement>();
public IEnumerable<IInteractionElement> InteractionVolumes
{
@ -358,6 +358,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (renderSource != null)
{
renderSource.BeforeDraw -= RenderSource_BeforeDraw;
renderSource = null;
}
if (sceneContext.Printer != null)
@ -383,6 +384,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
base.OnClosed(e);
// Clear lists and references
iavOverrides?.Clear();
iavMappings.Clear();
registeredIAVolumes.Clear();
drawables.Clear();
itemDrawables.Clear();
SelectedInteractionVolume = null;
HoveredInteractionVolume = null;
}
private bool FindInteractionVolumeHit(Ray ray, out InteractionVolume hitIAVolume, out IntersectInfo info)