]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
Fix for bug PAL7990 : Supervisor: application crashes.
authormkr <mkr@opencascade.com>
Fri, 21 Oct 2005 12:46:37 +0000 (12:46 +0000)
committermkr <mkr@opencascade.com>
Fri, 21 Oct 2005 12:46:37 +0000 (12:46 +0000)
src/GraphBase/DataFlowBase_Graph.cxx

index 24d4bbcf6d8ccc9f16832def1f11c5075d538005..ce2299e27cede36d061b6a88b36598b257d904e7 100644 (file)
@@ -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() ) {