Salome HOME
Set a default value of 1 for nbBranches of foreachloop in the built-in catalog.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Thu, 10 Sep 2015 15:46:31 +0000 (17:46 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Thu, 10 Sep 2015 15:46:31 +0000 (17:46 +0200)
There was a minor GUI issue where the displayed value of nbBranches was 1,
but actually it was not set.

src/engine/Runtime.cxx
src/runtime/RuntimeSALOME.cxx

index c54ce5925c0926f0c54ffebf90800ef935082e0b..91775a2c8a1206199340430049d140175f2a7ff1 100644 (file)
@@ -86,15 +86,10 @@ Runtime::Runtime()
   DEBTRACE( "_tc_stringpair refcnt: " << Runtime::_tc_stringpair->getRefCnt() );
   DEBTRACE( "_tc_propvec refcnt: " << Runtime::_tc_propvec->getRefCnt() );
   _builtinCatalog = new Catalog("builtins");
-  _builtinCatalog->_composednodeMap["Bloc"]=createBloc("Bloc");
-  _builtinCatalog->_composednodeMap["Switch"]=createSwitch("Switch");
-  _builtinCatalog->_composednodeMap["WhileLoop"]=createWhileLoop("WhileLoop");
-  _builtinCatalog->_composednodeMap["ForLoop"]=createForLoop("ForLoop");
-  _builtinCatalog->_composednodeMap["ForEachLoop_double"]=createForEachLoop("ForEachLoop_double",Runtime::_tc_double);
-  _builtinCatalog->_composednodeMap["ForEachLoop_string"]=createForEachLoop("ForEachLoop_string",Runtime::_tc_string);
-  _builtinCatalog->_composednodeMap["ForEachLoop_int"]=createForEachLoop("ForEachLoop_int",Runtime::_tc_int);
-  _builtinCatalog->_composednodeMap["ForEachLoop_bool"]=createForEachLoop("ForEachLoop_bool",Runtime::_tc_bool);
   std::map<std::string,TypeCode*>& typeMap=_builtinCatalog->_typeMap;
+  /* All composed node creations are moved to RuntimeSALOME::initBuiltins.
+     It is not safe to have all those calls to virtual functions (create*)
+     in the constructor. */
   Runtime::_tc_double->incrRef();
   typeMap["double"]=Runtime::_tc_double;
   Runtime::_tc_int->incrRef();
@@ -255,7 +250,9 @@ ForLoop* Runtime::createForLoop(const std::string& name)
 
 ForEachLoop* Runtime::createForEachLoop(const std::string& name,TypeCode *type)
 {
-  return new ForEachLoop(name,type);
+  ForEachLoop* ret = new ForEachLoop(name,type);
+  ret->edGetNbOfBranchesPort()->edInit(1);
+  return ret;
 }
 
 OptimizerLoop* Runtime::createOptimizerLoop(const std::string& name,const std::string& algLib,const std::string& factoryName,bool algInitOnFile,
index 1727e64269ae4f1282f5ea286b9966505f4b4c6d..0ac34e183a676cd83e037f493d6d6e1f60bf011e 100644 (file)
@@ -43,6 +43,7 @@
 #include "PresetPorts.hxx"
 #include "InputDataStreamPort.hxx"
 #include "OutputDataStreamPort.hxx"
+#include "Switch.hxx"
 #include "SalomeProc.hxx"
 #include "PyStdout.hxx"
 //Catalog Loaders
@@ -181,6 +182,14 @@ void RuntimeSALOME::initBuiltins()
   std::list<TypeCodeObjref *> ltc;
   typeMap["pyobj"]= createInterfaceTc("python:obj:1.0","pyobj",ltc);
   typeMap["seqpyobj"]= createSequenceTc("seqpyobj","seqpyobj",typeMap["pyobj"]);
+  composednodeMap["Bloc"]=createBloc("Bloc");
+  composednodeMap["Switch"]=createSwitch("Switch");
+  composednodeMap["WhileLoop"]=createWhileLoop("WhileLoop");
+  composednodeMap["ForLoop"]=createForLoop("ForLoop");
+  composednodeMap["ForEachLoop_double"]=createForEachLoop("ForEachLoop_double",Runtime::_tc_double);
+  composednodeMap["ForEachLoop_string"]=createForEachLoop("ForEachLoop_string",Runtime::_tc_string);
+  composednodeMap["ForEachLoop_int"]=createForEachLoop("ForEachLoop_int",Runtime::_tc_int);
+  composednodeMap["ForEachLoop_bool"]=createForEachLoop("ForEachLoop_bool",Runtime::_tc_bool);
   composednodeMap["ForEachLoop_pyobj"]=createForEachLoop("ForEachLoop_pyobj",typeMap["pyobj"]);;
   ENGINE::TypeCodeStruct *t = createStructTc("","Engines/dataref");
   t->addMember("ref",_tc_string);