From f07e1b64b4e7242ad9d20707ccceae4af08e0700 Mon Sep 17 00:00:00 2001 From: Tom Norris Date: Sun, 6 Feb 2022 13:23:44 -0800 Subject: [PATCH] bf-cross-node-crash fixing a crash that happends when you try to parent a node to a key --- Code/NodeCode/MainView.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Code/NodeCode/MainView.cs b/Code/NodeCode/MainView.cs index 543f509..2996d49 100644 --- a/Code/NodeCode/MainView.cs +++ b/Code/NodeCode/MainView.cs @@ -962,24 +962,32 @@ public void OnConnectionRequest( string from, int fromSlot, string to, int toSlo var rightGraph = _graph.GetNode( to ); Node rightSlot = rightGraph.GetSlot( toSlot ); - if( leftSlot is KeyLinkSlot keyLink ) + if( rightSlot is KeyAbstraction keyAbstraction ) { - if( !( rightSlot is KeySlot key ) ) + if( !( leftSlot is KeyLinkSlot link ) ) { - throw new Exception($"{leftSlot.Name} is not a KeyLinkSlot"); + _app.CatchException( new Exception($"{leftSlot.Name} is not a KeyLinkSlot")); + return; } - if( !keyLink.AddKey( key.GetKey ) ) return; + if( !link.AddKey( keyAbstraction.GetKey ) ) return; _graph.ConnectNode( @from, fromSlot, to, toSlot ); + + return; } - else if( leftSlot is LinkToChildSlot leftLink ) + + if( leftSlot is LinkToChildSlot leftLink ) { if( !( rightSlot is LinkToParentSlot rightLink) ) return; if( !leftLink.LinkChild( rightGraph ) ) return; rightLink.Link(leftLink); _graph.ConnectNode( @from, fromSlot, to, toSlot ); + + return; } + + _app.CatchException( new Exception("Connection not compatible")); } private void OnDisconnectionRequest( string from, int fromSlot, string to, int toSlot)