From 7e86313d7c82096f23323a4e64c2d09cb27d36ea Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Fri, 3 Apr 2026 21:34:25 -0400 Subject: [PATCH] fix: prevent Delete key from corrupting quantity during ActionClone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ObservableList.Remove fired ItemRemoved even when the item wasn't in the list, causing Plate to decrement Quantity.Nested for clone preview parts that were never added — producing -1 counts. Delete in PlateView now cancels ActionClone instead of trying to remove its preview parts. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest.Core/Collections/ObservableList.cs | 3 ++- OpenNest/Controls/PlateView.cs | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenNest.Core/Collections/ObservableList.cs b/OpenNest.Core/Collections/ObservableList.cs index 192c420..cd79bb2 100644 --- a/OpenNest.Core/Collections/ObservableList.cs +++ b/OpenNest.Core/Collections/ObservableList.cs @@ -46,7 +46,8 @@ namespace OpenNest.Collections public bool Remove(T item) { var success = items.Remove(item); - ItemRemoved?.Invoke(this, new ItemRemovedEventArgs(item, success)); + if (success) + ItemRemoved?.Invoke(this, new ItemRemovedEventArgs(item, success)); return success; } diff --git a/OpenNest/Controls/PlateView.cs b/OpenNest/Controls/PlateView.cs index d0c3792..5a454bc 100644 --- a/OpenNest/Controls/PlateView.cs +++ b/OpenNest/Controls/PlateView.cs @@ -386,7 +386,11 @@ namespace OpenNest.Controls switch (e.KeyCode) { case Keys.Delete: - if (selectedCutOff != null) + if (currentAction is ActionClone) + { + SetAction(typeof(ActionSelect)); + } + else if (selectedCutOff != null) { Plate.CutOffs.Remove(selectedCutOff); selectedCutOff = null;