Salome HOME
The final values of InPorts of EndSwitchNodes in a loop may be wrong
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_InNodeThreads.cxx
index 42661e2dfda57ac0ed65c790919ea761d19edffc..7ae01e5426cc6b925a8f85ccb8dc080106af583c 100644 (file)
@@ -799,14 +799,23 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
   bool LoopFinished = false ;
   bool SwitchFinished = false ;
 
-  if ( IsLoopNode() && GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
-    LoopBeginning = true ; // Beginning of Loop
+  if ( IsLoopNode() ) {
+    GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ;
+    if ( anOutLoopPort && anOutLoopPort->BoolValue() ) {
+      LoopBeginning = true ; // Beginning of Loop
+    }
   }
-  if ( IsEndLoopNode() && !GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
-    LoopFinished = true ; // End of Loop
+  if ( IsEndLoopNode() ) {
+    GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ;
+    if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) {
+      LoopFinished = true ; // End of Loop
+    }
   }
-  if ( IsEndSwitchNode() && !GetChangeNodeInGate()->GetOutPort()->BoolValue() ) {
-    SwitchFinished = true ; // End of Switch
+  if ( IsEndSwitchNode() ) {
+    GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ;
+    if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
+      SwitchFinished = true ; // End of Switch
+    }
   }
   cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
          << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << endl ;
@@ -1842,17 +1851,23 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
                << anOutPort->ChangeInPorts( j )->NodeName() << "( "
                << anOutPort->ChangeInPorts( j )->PortName() << " "
                << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
-        if ( strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
+       GraphBase::ComputingNode * aToNode ;
+        aToNode = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() ) ;
+// JR 12.01.2005 : the OutPort linked to the InPort of a EndSwitchNode was changed so final
+//                 values of InPorts of EndSwitchNode may be wrong
+        if ( !aToNode->IsEndSwitchNode() && 
+             strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
 // After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from
 // EndLoopNode or GOTONode. But if there is several nested loops we should re-establish.
           cdebug << ThreadNo()
-                 << " InNodeThreads::SetWaitingStates OutPort->ChangeInPorts( j )->OutPort()->NodeName "
-                 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << " != "
+                 << " InNodeThreads::SetWaitingStates Node " << Name() << " " 
+                 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
+                 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
                  << Name() << " : Restored to " << anOutPort->NodeName() << "( "
                  << anOutPort->PortName() << " )" << endl ;
           anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
         }
-        GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ;
+        GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ;
         if ( aNode != EndNode ) {
           aNode->SetWaitingStates( EndNode ) ;
        }