fix: prevent Delete key from corrupting quantity during ActionClone
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) <noreply@anthropic.com>
This commit is contained in:
@@ -46,7 +46,8 @@ namespace OpenNest.Collections
|
||||
public bool Remove(T item)
|
||||
{
|
||||
var success = items.Remove(item);
|
||||
ItemRemoved?.Invoke(this, new ItemRemovedEventArgs<T>(item, success));
|
||||
if (success)
|
||||
ItemRemoved?.Invoke(this, new ItemRemovedEventArgs<T>(item, success));
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user