Fixed a null reference error that happened when a step was deleted from the tree. B2016-105

Adding a new step from the section node in a tree will now consistently add the new step at the beginning of that section – whether the procedure editor is open or not. – B2016-002
This commit is contained in:
John Jenko 2016-04-21 17:31:33 +00:00
parent 77d0446631
commit ca12e39a6b
2 changed files with 10 additions and 3 deletions

View File

@ -1016,7 +1016,8 @@ namespace VEPROMS
if (displayHistory.MyEditItem != null && displayHistory.MyItemInfo.MyProcedure.ItemID == args.MyItemInfo.ItemID) if (displayHistory.MyEditItem != null && displayHistory.MyItemInfo.MyProcedure.ItemID == args.MyItemInfo.ItemID)
displayHistory.MyEditItem = null; displayHistory.MyEditItem = null;
// bug fix B2016-005 - set MyCopyStep to null. This will take the paste options off of the tree node context menus. jsj 4-19-2016 // bug fix B2016-005 - set MyCopyStep to null. This will take the paste options off of the tree node context menus. jsj 4-19-2016
if (args.MyItemInfo.ItemID == tc.MyCopyStep.ItemID) // B2016-105 - added null reference check -jsj
if (tc.MyCopyStep != null && args.MyItemInfo.ItemID == tc.MyCopyStep.ItemID)
tc.MyCopyStep = null; tc.MyCopyStep = null;
bool rtval = tc.DeleteRTBItem(args.MyItemInfo); bool rtval = tc.DeleteRTBItem(args.MyItemInfo);
// Also disable the paste options on the ribbon if it is open. jsj 4-19-2016 // Also disable the paste options on the ribbon if it is open. jsj 4-19-2016

View File

@ -2708,12 +2708,18 @@ namespace Volian.Controls.Library
else else
{ {
// The parent step was not open in the step editor, just create new step and add treenode. // The parent step was not open in the step editor, just create new step and add treenode.
using (Step step = Step.MakeStep(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Step), null, "New Step", 20002, E_FromType.Step)) // this line (below) adds the new step to the bottom of the section, the other line (not commented) adds it to the top. Bug fix B2016-002
//using (Step step = Step.MakeStep(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Step), null, "New Step", 20002, E_FromType.Step))
using (Step step = Step.MakeStep(_LastItemInfo, null , null, "New Step", 20002, E_FromType.Step))
{ {
ShowBrokenRules(step.BrokenRulesCollection); ShowBrokenRules(step.BrokenRulesCollection);
SetLastValues(StepInfo.Get(step.ItemID)); SetLastValues(StepInfo.Get(step.ItemID));
tn = new VETreeNode(_LastStepInfo); tn = new VETreeNode(_LastStepInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list. //SelectedNode.Nodes.Add(tn); // add tree node to end of list.
_LastStepInfo.UpdateTransitionText();
_LastStepInfo.UpdateROText();
TreeNode par = SelectedNode;
par.Nodes.Insert(0, tn);
} }
} }