B2024-045, B2024-049, B2024-050 crash on paste/replace

This commit is contained in:
2024-07-31 07:21:30 -04:00
parent 35c7b2b0cf
commit 870bba0aa6
3 changed files with 34 additions and 20 deletions

View File

@@ -1309,8 +1309,7 @@ namespace VEPROMS.CSLA.Library
else if (addType == EAddpingPart.Replace) // what about user interface for enhanced pasted steps?
{
ItemInfo enhReplaceItem = ItemInfo.Get(edSource.ItemID);
TreeNode trn = null;
newEnhancedItemInfo = Item.PasteReplace(enhReplaceItem, tmpCopyEnhancedID, chgid, trn);
newEnhancedItemInfo = Item.PasteReplace(enhReplaceItem, tmpCopyEnhancedID, chgid);
}
// update the config data for the new enhanced item (procedure, section or step) to point back to the correct source
@@ -2498,16 +2497,15 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region PasteReplace
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace)
// B2024-045, 049 and 050: remove the treenode that was passed in - adjust tree from user interface code, not in item extension
// code (the 2 PasteReplace methods here had a treenode passed in)
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid)
{
bool tmp = false;
return PasteReplace(itemInfo, copyStartID, chgid, treeNodeReplace, ref tmp);
return PasteReplace(itemInfo, copyStartID, chgid, ref tmp);
}
// B2017-179 return a bool (firstTrans) if we could not replace the step but the user wants to position to the first transition that needs resolved
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace, ref bool firstTrans)
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, ref bool firstTrans)
{
firstTrans = false;
if (!CanDeleteObject())
@@ -2565,10 +2563,11 @@ namespace VEPROMS.CSLA.Library
}
else
{
//Create tree node for copied procedure when no other procedures exist in the working draft (treeNodeReplace)
VETreeNode tn = null;
tn = new VETreeNode(newItemInfo);
treeNodeReplace.Nodes.Add(tn);
// B2024-045, 049 and 050: if not a single procedure replace, update user interface by using the 'OnNewChild'. Single
// procedure's MyParent is null because its parent is a working draft (docversion) since MyParent's type is iteminfo.
// For the single procedure case, the user interface code in vlntreeview will update the tree.
if (newItemInfo.MyParent != null)
newItemInfo.MyParent.OnNewChild(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Child));
}
return newItemInfo;
}