B2024-045, B2024-049, B2024-050 crash on paste/replace
This commit is contained in:
@@ -1844,8 +1844,8 @@ namespace Volian.Controls.Library
|
||||
bool gotoFirstTrans = false;
|
||||
try
|
||||
{
|
||||
TreeNode treeNodeReplace = null;
|
||||
newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID, GetChangeId(MyItemInfo), treeNodeReplace, ref gotoFirstTrans);
|
||||
// B2024-045, 049 and 050: do not pass in a tree node to Item.PasteReplace
|
||||
newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID, GetChangeId(MyItemInfo), ref gotoFirstTrans);
|
||||
if (gotoFirstTrans) //B2017-179 could not replace step, we are positioning onto the first transition that needs resolved
|
||||
{
|
||||
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(newItemInfo);
|
||||
|
@@ -2408,7 +2408,6 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
VETreeNode tn = SelectedNode as VETreeNode;
|
||||
TreeNode treeNodeReplace = SelectedNode.Parent; //Get Tree Node of Parent we are proc we are placing into.
|
||||
DocVersionInfo dvi = tn.VEObject as DocVersionInfo;
|
||||
// Check for paste into a docversion - queries/code is different than paste related to an item (into a proc or section)
|
||||
if (dvi != null)
|
||||
@@ -2445,11 +2444,27 @@ namespace Volian.Controls.Library
|
||||
PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID);
|
||||
else if (p.IndexOf("Replace") > -1)
|
||||
{
|
||||
PasteReplace(tn, iiClipboard.ItemID, treeNodeReplace);
|
||||
bool OnlyProc = iiPaste.IsProcedure && iiPaste.MyPrevious == null && (iiPaste.NextItems == null || iiPaste.NextItems.Count == 0);
|
||||
VETreeNode tmp = null;
|
||||
if (OnlyProc)
|
||||
{
|
||||
VETreeNode tnp = SelectedNode as VETreeNode;
|
||||
tmp = tnp == null ? null : tnp.Parent as VETreeNode;
|
||||
}
|
||||
ItemInfo repitem = PasteReplace(tn, iiClipboard.ItemID);
|
||||
// B2024-045, 049 and 050: The treenode was passed into the business object's replace but sometimes it was null. And this
|
||||
// wasn't working if it was a single procedure in a working Draft. Adjust the tree here if single procedure in working draft.
|
||||
if (OnlyProc && repitem != null && tmp != null)
|
||||
{
|
||||
VETreeNode tn1 = new VETreeNode(repitem);
|
||||
tmp.Nodes.Add(tn1);
|
||||
SelectedNode = tn1;
|
||||
}
|
||||
}
|
||||
else // paste as child
|
||||
PasteAsChild(tn, iiClipboard.ItemID);
|
||||
|
||||
|
||||
//if (p.IndexOf("Replace") <= -1)
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
@@ -2541,18 +2556,19 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
SelectedNode = (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
|
||||
}
|
||||
private void PasteReplace(VETreeNode tn, int copyStartID, TreeNode treeNodeReplace)
|
||||
private ItemInfo PasteReplace(VETreeNode tn, int copyStartID)
|
||||
{
|
||||
VETreeNode prevtn = (VETreeNode) tn.PrevNode;
|
||||
VETreeNode partn = (VETreeNode) tn.Parent;
|
||||
ItemInfo ii = tn.VEObject as ItemInfo;
|
||||
// F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format
|
||||
ItemInfo.PasteStepIsWithinDefinedSubStepLevels(copyStartID, ii, true);
|
||||
ItemInfo replItemInfo = null;
|
||||
if (!OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, ItemInfo.EAddpingPart.Replace, ii.MyContent.Type)))
|
||||
{
|
||||
// first, check if a changeid is required.
|
||||
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
|
||||
ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID, chgId, treeNodeReplace);
|
||||
replItemInfo = Item.PasteReplace(ii, copyStartID, chgId);
|
||||
|
||||
StepConfig replItemConfig = ii.MyConfig as StepConfig;
|
||||
if (replItemInfo != null)
|
||||
@@ -2562,8 +2578,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
// B2018-047: was crashing on the following line (before change it was casting the result to a VETreeNote when the partn.FirstNode was just a TreeNode)
|
||||
SelectedNode = prevtn != null ? prevtn.NextNode : partn.FirstNode;
|
||||
|
||||
|
||||
return replItemInfo;
|
||||
}
|
||||
public void PasteRepalceEmpty(VETreeNode tn, int copyStartID)
|
||||
{
|
||||
|
Reference in New Issue
Block a user