@@ -868,21 +868,35 @@ qx.Class.define("osparc.data.model.Node", {
868868 return ;
869869 }
870870
871- // create automatic port connections
872- let autoConnections = 0 ;
873- const outPorts = node1 . getOutputs ( ) ;
874- const inPorts = node2 . getInputs ( ) ;
875- for ( const outPort in outPorts ) {
876- for ( const inPort in inPorts ) {
877- if ( await node2 . addPortLink ( inPort , node1 . getNodeId ( ) , outPort ) ) {
878- autoConnections ++ ;
879- break ;
871+ const autoConnectPorts = async ( ) => {
872+ // create automatic port connections
873+ let autoConnections = 0 ;
874+ const outPorts = node1 . getOutputs ( ) ;
875+ const inPorts = node2 . getInputs ( ) ;
876+ for ( const outPort in outPorts ) {
877+ for ( const inPort in inPorts ) {
878+ if ( await node2 . addPortLink ( inPort , node1 . getNodeId ( ) , outPort ) ) {
879+ autoConnections ++ ;
880+ break ;
881+ }
880882 }
881883 }
884+ if ( autoConnections ) {
885+ const flashMessenger = osparc . FlashMessenger . getInstance ( ) ;
886+ flashMessenger . logAs ( autoConnections + this . tr ( " ports auto connected" ) , "INFO" ) ;
887+ }
882888 }
883- if ( autoConnections ) {
884- const flashMessenger = osparc . FlashMessenger . getInstance ( ) ;
885- flashMessenger . logAs ( autoConnections + this . tr ( " ports auto connected" ) , "INFO" ) ;
889+ if ( node1 . getMetadata ( ) && node2 . getMetadata ( ) ) {
890+ autoConnectPorts ( ) ;
891+ } else {
892+ // wait for both metadata to be loaded
893+ const onMetadataChanged = ( ) => {
894+ if ( node1 . getMetadata ( ) && node2 . getMetadata ( ) ) {
895+ autoConnectPorts ( ) ;
896+ }
897+ } ;
898+ node1 . addListenerOnce ( "changeMetadata" , onMetadataChanged , this ) ;
899+ node2 . addListenerOnce ( "changeMetadata" , onMetadataChanged , this ) ;
886900 }
887901 } ,
888902
0 commit comments