]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
Fix for PAL12895 : EDF218 SUPERV Problem with "Embedded Python-2.3.4" ??? V3.2.0.
authormkr <mkr@opencascade.com>
Mon, 10 Jul 2006 08:57:32 +0000 (08:57 +0000)
committermkr <mkr@opencascade.com>
Mon, 10 Jul 2006 08:57:32 +0000 (08:57 +0000)
src/GraphExecutor/DataFlowExecutor_InNode.cxx
src/GraphExecutor/DataFlowExecutor_OutNode.cxx

index fde0428b590d02df89064b78dadef7597d170a6b..e914e9c9c1c2bd6f2326f56faf1504da93ed3f94 100644 (file)
@@ -1521,6 +1521,7 @@ void GraphExecutor::InNode::InitialState()
 }
 
 bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
+  //JR Look at DataFlowExecutor for the meaning of WithErr
   cdebug_in << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " WithErr " << WithErr
             << " PyFuncRunned() " << PyFuncRunned() << endl;
   bool Err = false ;
@@ -1537,7 +1538,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
         PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
                                        InLineNode()->PythonFunction() ,
                                        OneErr ) ;
-        InLineNode()->PyRunMethod( PyRunMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyRunMethod ) {
+          InLineNode()->PyRunMethod( PyRunMethod ) ;
+       }
+        else if ( WithErr && strlen( InLineNode()->PyFuncName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1554,7 +1561,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
         PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() ,
                                         LoopNode()->MorePythonFunction() ,
                                         OneErr ) ;
-        LoopNode()->PyMoreMethod( PyMoreMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyMoreMethod ) {
+          LoopNode()->PyMoreMethod( PyMoreMethod ) ;
+       }
+        else if ( WithErr && strlen( LoopNode()->PyMoreName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1571,7 +1584,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
         PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() ,
                                         LoopNode()->NextPythonFunction() ,
                                         OneErr ) ;
-        LoopNode()->PyNextMethod( PyNextMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyNextMethod ) {
+          LoopNode()->PyNextMethod( PyNextMethod ) ;
+       }
+        else if ( WithErr && strlen( LoopNode()->PyNextName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1580,11 +1599,10 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
                                 string( Name() ) ;
         _OutNode->Graph()->SetMessages( anErrorMessage ) ;
       }
-      // PAL12854 -->
+      //JR Debug 12854
       if ( Err ) {
         PyFuncRunned( false ) ;
       }
-      // PAL12854 <--
       cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod(Init) "
              << PyRunMethod << " PyMoreMethod " << PyMoreMethod << " PyNextMethod " << PyNextMethod
              << endl;
@@ -1598,7 +1616,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
        PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
                                        InLineNode()->PythonFunction() ,
                                        OneErr ) ;
-        InLineNode()->PyRunMethod( PyRunMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyRunMethod != NULL ) {
+          InLineNode()->PyRunMethod( PyRunMethod ) ;
+       }
+        else if ( WithErr && strlen( InLineNode()->PyFuncName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1619,7 +1643,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
         PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
                                        InLineNode()->PythonFunction() ,
                                        OneErr ) ;
-        InLineNode()->PyRunMethod( PyRunMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyRunMethod != NULL ) {
+          InLineNode()->PyRunMethod( PyRunMethod ) ;
+       }
+        else if ( WithErr && strlen( InLineNode()->PyFuncName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1631,10 +1661,11 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
       cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl;
     }
   }
-  Err = WithErr && Err ;
+  //JR Look at DataFlowExecutor :
+  //  Err = WithErr && Err ;
   cdebug_out << "GraphExecutor::InNode::InitPythonFunctions " << Name() ;
-  if ( Err ) {
-    cdebug << " Error " << Err ;
+  if ( WithErr && Err ) {
+    cdebug << " Error " << WithErr && Err ;
   }
   cdebug << endl;
   return !Err ;
index fd8c1a177c3d0e3133f86c99e8a639c1308a4aed..ef342d0572bed16b99fdb15078a9d58cd181759a 100644 (file)
@@ -519,6 +519,7 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
     _JustStarted = true ;
     RetVal = true ;
     int i ;
+    bool again = true ;
     for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
       GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ;
       anInNode->OutNode( this ) ;
@@ -536,7 +537,12 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
       }
       anInNode->InitialState() ;
       if ( anInNode->IsOneOfInLineNodes() ) {
-        anInNode->InitPythonFunctions( false ) ;
+       //JR with Python2.3.4, we may get an error because of a normal previous error
+        bool sts = anInNode->InitPythonFunctions( false ) ;
+        if ( again && !sts ) {
+          sts = anInNode->InitPythonFunctions( false ) ;
+          again = false ;
+       }
       }
     }
 // One more time because inline nodes may share one definition of the same function
@@ -573,6 +579,9 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
       }
     }
     */
+    //JR Debug : if there was an error in initialisation of python functions,
+    //           we must not try to execute the graph.
+    if ( RetVal ) {
     if ( Graph()->GraphMacroLevel() != 0 ) {
       cdebug << "GraphExecutor::OutNode::Run Execution starting GraphExecutor::Action_DataOk_RunService Node "
              << Name() << " GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
@@ -700,6 +709,19 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
 //      Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
       RetVal = true ;
     }
+    //JR Debug
+    }
+    else {
+      State( GraphExecutor::ErroredState ) ;
+      Done( true ) ;
+      if ( IsDone() ) {
+        cdebug << " ==> theAutomaton->Executed() " << endl ;
+        theAutomaton->Executed() ;
+      }
+      else {
+        cdebug << " NO theAutomaton->Executed() " << endl ;
+      }
+    }
   }
   else {
 // PAL 8515