Skip to content

Commit e90b4a7

Browse files
committed
Merge branch 'develop'
2 parents 768c6de + 4bda0ed commit e90b4a7

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

SimpleStateMachineNodeEditor/ViewModel/NodesCanvas/ViewModelNodesCanvasCommands.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,35 @@ private void Open()
324324

325325
#region setup start state
326326

327-
var startState = stateMachineXElement.Element("StartState")?.Attribute("Name")?.Value;
328-
329-
if (string.IsNullOrEmpty(startState))
327+
var startStateElement = stateMachineXElement.Element("StartState");
328+
if (startStateElement == null)
329+
{
330330
this.SetupStartState();
331+
}
331332
else
332-
this.SetAsStart(this.Nodes.Items.Single(x => x.Name == startState));
333+
{
334+
var startStateAttribute = startStateElement.Attribute("Name");
335+
if (startStateAttribute == null)
336+
{
337+
Error("Start state element don't has name attribute");
338+
return;
339+
}
340+
else
341+
{
342+
string startStateName = startStateAttribute.Value;
343+
var startNode = this.Nodes.Items.SingleOrDefault(x => x.Name == startStateName);
344+
if (startNode == null)
345+
{
346+
Error(string.Format("Unable to set start state. Node with name \"{0}\" don't exists", startStateName));
347+
return;
348+
}
349+
else
350+
{
351+
this.SetAsStart(startNode);
352+
}
353+
}
354+
355+
}
333356

334357
#endregion setup start state
335358

0 commit comments

Comments
 (0)