From 5163b02f899ac53575e3e49023e5e5d4f41b87e1 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Tue, 7 Apr 2026 22:01:50 -0400 Subject: [PATCH] fix: increase max zoom and handle GDI+ thread race in PlateView Raise ViewScaleMax from 3000 to 10000 for deeper zoom. Catch InvalidOperationException in hoverTimer_Elapsed when GraphicsPath is concurrently used by the paint thread. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest/Controls/DrawControl.cs | 2 +- OpenNest/Controls/PlateView.cs | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/OpenNest/Controls/DrawControl.cs b/OpenNest/Controls/DrawControl.cs index ba50526..ebaf59c 100644 --- a/OpenNest/Controls/DrawControl.cs +++ b/OpenNest/Controls/DrawControl.cs @@ -29,7 +29,7 @@ namespace OpenNest.Controls { ViewScale = 1.0f; ViewScaleMin = 0.3f; - ViewScaleMax = 3000; + ViewScaleMax = 10000; origin = new PointF(100, 100); } diff --git a/OpenNest/Controls/PlateView.cs b/OpenNest/Controls/PlateView.cs index 5c2d691..b1a0fe2 100644 --- a/OpenNest/Controls/PlateView.cs +++ b/OpenNest/Controls/PlateView.cs @@ -627,15 +627,23 @@ namespace OpenNest.Controls { var graphPt = PointControlToGraph(hoverPoint); LayoutPart hitPart = null; - for (var i = parts.Count - 1; i >= 0; --i) + try { - if (parts[i].Path.GetBounds().Contains(graphPt) && - parts[i].Path.IsVisible(graphPt)) + for (var i = parts.Count - 1; i >= 0; --i) { - hitPart = parts[i]; - break; + if (parts[i].Path.GetBounds().Contains(graphPt) && + parts[i].Path.IsVisible(graphPt)) + { + hitPart = parts[i]; + break; + } } } + catch (InvalidOperationException) + { + // GraphicsPath in use by paint thread — skip this hover tick + return; + } hoveredPart = hitPart; showTooltip = hitPart != null;