From fff8eb6215c7d6031df7e661a749a1952ecc5ba2 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 5 May 2021 15:13:23 -0700 Subject: [PATCH] protect against null --- .../ScaleControls/ScaleDiameterControl.cs | 10 ++++----- .../ScaleControls/ScaleMatrixCornerControl.cs | 10 ++++----- .../ScaleWidthDepthCornerControl.cs | 22 +++++++++---------- .../ScaleWidthDepthEdgeControl.cs | 8 +++---- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleDiameterControl.cs b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleDiameterControl.cs index 6b8d279af..4ed30d73d 100644 --- a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleDiameterControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleDiameterControl.cs @@ -200,12 +200,12 @@ namespace MatterHackers.Plugins.EditorTools //Object3DControlContext.World.RenderPlane(hitPlane.Plane, Color.Red, true, 50, 3); //Object3DControlContext.World.RenderPlane(initialHitPosition, hitPlane.Plane.Normal, Color.Red, true, 50, 3); } - } - if (shouldDrawScaleControls - && (MouseIsOver || MouseDownOnControl)) - { - DrawMeasureLines(e); + if (shouldDrawScaleControls + && (MouseIsOver || MouseDownOnControl)) + { + DrawMeasureLines(e); + } } base.Draw(e); diff --git a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixCornerControl.cs b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixCornerControl.cs index 6dc6f67a1..cb7cb80aa 100644 --- a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixCornerControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixCornerControl.cs @@ -191,12 +191,12 @@ namespace MatterHackers.Plugins.EditorTools Vector3 endPosition = GetCornerPosition(selectedItem, (quadrantIndex + 1) % 4); Object3DControlContext.World.Render3DLine(startPosition, endPosition, theme.TextColor.WithAlpha(e.Alpha0to255), e.ZBuffered, GuiWidget.DeviceScale); } - } - if (MouseIsOver || MouseDownOnControl) - { - DrawMeasureLines(e, quadrantIndex); - DrawMeasureLines(e, quadrantIndex + 1); + if (MouseIsOver || MouseDownOnControl) + { + DrawMeasureLines(e, quadrantIndex); + DrawMeasureLines(e, quadrantIndex + 1); + } } base.Draw(e); diff --git a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleWidthDepthCornerControl.cs b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleWidthDepthCornerControl.cs index 3c3fff978..176bf2bc1 100644 --- a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleWidthDepthCornerControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleWidthDepthCornerControl.cs @@ -181,19 +181,19 @@ namespace MatterHackers.Plugins.EditorTools //Object3DControlContext.World.RenderPlane(hitPlane.Plane, Color.Red, true, 30, 3); //Object3DControlContext.World.RenderPlane(initialHitPosition, hitPlane.Plane.Normal, Color.Red, true, 30, 3); } - } - if (e != null && selectedItem != null) - { - Vector3 startPosition = ObjectSpace.GetCornerPosition(selectedItem, quadrantIndex); - Vector3 endPosition = ObjectSpace.GetCornerPosition(selectedItem, (quadrantIndex + 1) % 4); - Object3DControlContext.World.Render3DLine(startPosition, endPosition, theme.TextColor.WithAlpha(e.Alpha0to255), e.ZBuffered, GuiWidget.DeviceScale); - } + if (e != null) + { + Vector3 startPosition = ObjectSpace.GetCornerPosition(selectedItem, quadrantIndex); + Vector3 endPosition = ObjectSpace.GetCornerPosition(selectedItem, (quadrantIndex + 1) % 4); + Object3DControlContext.World.Render3DLine(startPosition, endPosition, theme.TextColor.WithAlpha(e.Alpha0to255), e.ZBuffered, GuiWidget.DeviceScale); + } - if (MouseIsOver || MouseDownOnControl) - { - DrawMeasureLines(e, quadrantIndex); - DrawMeasureLines(e, quadrantIndex + 1); + if (MouseIsOver || MouseDownOnControl) + { + DrawMeasureLines(e, quadrantIndex); + DrawMeasureLines(e, quadrantIndex + 1); + } } base.Draw(e); diff --git a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleWidthDepthEdgeControl.cs b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleWidthDepthEdgeControl.cs index f8e2906e2..a781cf0f4 100644 --- a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleWidthDepthEdgeControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleWidthDepthEdgeControl.cs @@ -187,11 +187,11 @@ namespace MatterHackers.Plugins.EditorTools //Object3DControlContext.World.RenderPlane(hitPlane.Plane, Color.Red, true, 50, 3); //Object3DControlContext.World.RenderPlane(initialHitPosition, hitPlane.Plane.Normal, Color.Red, true, 50, 3); } - } - if (MouseIsOver || MouseDownOnControl) - { - DrawMeasureLines(e); + if (MouseIsOver || MouseDownOnControl) + { + DrawMeasureLines(e); + } } base.Draw(e);