From 19b631ff461b83f5882c61c15b4354ae65c87bfa Mon Sep 17 00:00:00 2001
From: Francois Henrotte <francois.henrotte@ulg.ac.be>
Date: Thu, 8 May 2014 14:11:08 +0000
Subject: [PATCH] solved a communication problem in onelab.call

---
 Common/OpenFile.cpp                                        | 1 -
 Common/onelabUtils.cpp                                     | 4 ++--
 Fltk/onelabGroup.cpp                                       | 7 ++++---
 .../HighOrderMeshOptimizer/OptHomIntegralBoundaryDist.cpp  | 3 ++-
 contrib/onelab/python/onelab.py                            | 3 ++-
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp
index b4e0bc686a..929ca952da 100644
--- a/Common/OpenFile.cpp
+++ b/Common/OpenFile.cpp
@@ -439,7 +439,6 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setWindowTit
     int num = defineSolver(split[1]);
     opt_solver_executable(num, GMSH_SET, fileName);
     CTX::instance()->launchSolverAtStartup = num;
-    //Msg::SetOnelabNumber("0Metamodel/Batch", CTX::instance()->batch, false);
     return 1;
   }
 #endif
diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp
index 295fff51b5..b152f8df5b 100644
--- a/Common/onelabUtils.cpp
+++ b/Common/onelabUtils.cpp
@@ -315,8 +315,8 @@ namespace onelabUtils {
     else if(action == "check"){
       if(onelab::server::instance()->getChanged("Gmsh") ||
          modelName != GModel::current()->getName()){
-        // reload geometry if Gmsh parameters have been modified or if the model
-        // name has changed
+        // reload geometry if Gmsh parameters have been modified or
+        // if the model name has changed
         modelName = GModel::current()->getName();
         redraw = true;
         OpenProject(GModel::current()->getFileName(), false);
diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp
index e797c6f372..7fe5b1ac7d 100644
--- a/Fltk/onelabGroup.cpp
+++ b/Fltk/onelabGroup.cpp
@@ -855,7 +855,8 @@ void onelab_cb(Fl_Widget *w, void *data)
     if(fileChooser(FILE_CHOOSER_SINGLE, "Load", "*.db", db.c_str()))
       loadDb(fileChooserGetName(1));
 
-    // switch to "restore" mode" (use archived solution files)
+    // switch to "restore" mode" 
+    // (the metamodel will use archived solution files)
     std::vector<onelab::number> pn;
     onelab::server::instance()->get(pn,"0Metamodel/9Use restored solution");
     if(pn.size()){
@@ -881,10 +882,9 @@ void onelab_cb(Fl_Widget *w, void *data)
   onelab::server::instance()->get(pn, "IsPyMetamodel");
   bool isPyMetamodel = (pn.size() && pn[0].getValue());
 
-
   do{ // enter loop
 
-    // if the client is a not a metamodel, run Gmsh
+    // if the client is not a python metamodel, run Gmsh
     if(!isPyMetamodel){
       if(onelabUtils::runGmshClient(action, CTX::instance()->solver.autoMesh))
         drawContext::global()->draw();
@@ -913,6 +913,7 @@ void onelab_cb(Fl_Widget *w, void *data)
       }
       if(FlGui::instance()->onelab->stop()) break;
     }
+
     // after computing, all parameters are set unchanged
     if(action == "compute"){
       onelab::server::instance()->setChanged(false);
diff --git a/contrib/HighOrderMeshOptimizer/OptHomIntegralBoundaryDist.cpp b/contrib/HighOrderMeshOptimizer/OptHomIntegralBoundaryDist.cpp
index 954302a0a0..9df0dcde51 100644
--- a/contrib/HighOrderMeshOptimizer/OptHomIntegralBoundaryDist.cpp
+++ b/contrib/HighOrderMeshOptimizer/OptHomIntegralBoundaryDist.cpp
@@ -243,8 +243,9 @@ double computeBndDistGb(GEdge *edge, std::vector<double> & params, // the model
 
 double computeBndDistG_(GEdge *edge, std::vector<double> & p, // the model edge
 		       const nodalBasis &basis, const std::vector<SPoint3> &xyz,
-		       const unsigned int N) // the mesh edge
+		       const unsigned int NN) // the mesh edge
 {
+  const unsigned int N = 256;
   std::vector<int> o;
   o.push_back(0);
   for (unsigned int i=2; i < p.size();i++)o.push_back(i);
diff --git a/contrib/onelab/python/onelab.py b/contrib/onelab/python/onelab.py
index f2b3344304..c7d7e07ce7 100755
--- a/contrib/onelab/python/onelab.py
+++ b/contrib/onelab/python/onelab.py
@@ -446,7 +446,8 @@ class client :
     if result == 0 :
       self._send(self._GMSH_INFO, 'call \"' + ' '.join(argv) + '\"')
     else :
-      self._send(self._GMSH_ERROR, 'call failed !!\n' + call.stderr.read().encode('utf-8'))
+      for line in iter(call.stderr.readline, b''):
+        self._send(self._GMSH_ERROR, line.rstrip().encode('utf-8'))
       
   def upload(self, here, there, remote='') :
     if not here or not there :
-- 
GitLab