From a276b775b158935de8d14b51b9373d3172e4a6ef Mon Sep 17 00:00:00 2001 From: mkr Date: Fri, 21 Oct 2005 12:46:37 +0000 Subject: [PATCH] Fix for bug PAL7990 : Supervisor: application crashes. --- src/GraphBase/DataFlowBase_Graph.cxx | 60 ++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx index 24d4bbc..ce2299e 100644 --- a/src/GraphBase/DataFlowBase_Graph.cxx +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -748,11 +748,16 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { } } // Remove the InPort of the EndSwitchNode from that OutPort +// PAL7990 : +// the InPort of the EndSwitchNode from that OutPort was already removed by +// anInPort->RemoveOutPort done above : +#if 0 RetVal = anOutPort->RemoveInPort( anInPort ) ; if ( !RetVal ) { cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ; break ; } +#endif } } } @@ -790,11 +795,50 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ; break ; } +// PAL7990 : the InPort of the EndSwitchNode from that OutPort was already removed by +// anInPort->RemoveOutPort done above : +#if 0 RetVal = anOutPort->RemoveInPort( anInPort ) ; if ( !RetVal ) { cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ; break ; } +#endif + if ( ToNode->IsEndSwitchNode() ) { // PAL7990 + int i ; + int done = false ; + for ( i = 0 ; i < ToNode->LinkedFromNodesSize() ; i++ ) { + GraphBase::StreamNode * fromNode = ToNode->LinkedFromNodes( i ) ; +// Not the node that we are deleting ... : + if ( strcmp( fromNode->Name() , aNode->Name() ) ) { + int j ; + for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) { + GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ; + int k ; + for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) { + if ( strcmp( ToNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) { + if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) { +// Restore an OutPort in the InPort + anInPort->ChangeOutPort( fromOutPort ) ; + cdebug << "Graph::RemoveNode reestablish " << fromOutPort->NodeName() << "( " + << fromOutPort->PortName() << " ) in the InPort of EndSwitch : " + << ToNode->Name() << "( " << anInPort->PortName() << " )" + << anInPort->Kind() << " " << anInPort->PortStatus() << endl; + done = true ; + break ; + } + } + } + if ( done ) { + break ; + } + } + if ( done ) { + break ; + } + } + } + } } } if ( !RetVal ) { @@ -825,7 +869,7 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) { theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ; theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ; - CoupledIndex = GetGraphNodeIndex( theCoupledNode->Name() ) ; + //CoupledIndex = GetGraphNodeIndex( theCoupledNode->Name() ) ; } delete aNode ; _GraphNodesSize -= 1 ; @@ -837,6 +881,8 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { _MapOfGraphNodes.erase( aNodeName ) ; // Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode : if ( theCoupledNode ) { +// from dev version -> JR 02.02.2005 DEBUG : CoupledIndex must be here after the delete of aNode (not before) + CoupledIndex = GetGraphNodeIndex( theCoupledNode->Name() ) ; delete theCoupledNode ; _GraphNodesSize -= 1 ; for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) { @@ -1212,8 +1258,16 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName , fromNode->RemoveLinkedNode( toNode ) ; } } - if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) { - anOutPort->Kind( SUPERV::InLineParameter ) ; + +// from JR PAL7990 : a SwitchPort is an OutPort of a SwitchNode connected to a InGate Port +//Debug : change the kind only if there is no other InGate connected to the OutPort + if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && anOutPort->InPortsSize() == 0 ) { + if ( !toNode->IsEndSwitchNode() ) { + anOutPort->Kind( SUPERV::InLineParameter ) ; + } + else if ( !anInPort->IsGate() ) { + anOutPort->Kind( SUPERV::InLineParameter ) ; + } } // JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be linked !!! if ( toNode->IsEndSwitchNode() ) { -- 2.39.2