From adbd08233cebfdd79988b3bc26d0f0e290fb83cd Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 9 Feb 2012 07:19:53 +0000
Subject: [PATCH] don't change attributes changed server-side

---
 Common/GmshMessage.cpp | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp
index 961f528b1d..0d19a5e309 100644
--- a/Common/GmshMessage.cpp
+++ b/Common/GmshMessage.cpp
@@ -638,8 +638,16 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
 
   std::vector<onelab::number> ps;
   _onelabClient->get(ps, name);
+  bool noRange = true, noChoices = true, noLoop = true, noGraph = true;
   if(ps.size()){ // use value from server
     val[0] = ps[0].getValue();
+    // keep track of these attributes, which can be changed server-side
+    if(ps[0].getMin() != -onelab::parameter::maxNumber() ||
+       ps[0].getMax() != onelab::parameter::maxNumber() ||
+       ps[0].getStep() != 0.) noRange = false;
+    if(ps[0].getChoices().size()) noChoices = false;
+    if(ps[0].getAttribute("Loop").size()) noLoop = false;
+    if(ps[0].getAttribute("Graph").size()) noGraph = false;
   }
   else{
     ps.resize(1);
@@ -647,26 +655,26 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
     ps[0].setValue(val[0]);
   }
   // send updated parameter to server
-  if(fopt.count("Range") && fopt["Range"].size() == 2){
+  if(noRange && fopt.count("Range") && fopt["Range"].size() == 2){
     ps[0].setMin(fopt["Range"][0]); ps[0].setMax(fopt["Range"][1]);
   }
-  else if(fopt.count("Min") && fopt.count("Max")){
+  else if(noRange && fopt.count("Min") && fopt.count("Max")){
     ps[0].setMin(fopt["Min"][0]); ps[0].setMax(fopt["Max"][0]);
   }
-  else if(fopt.count("Min")){
+  else if(noRange && fopt.count("Min")){
     ps[0].setMin(fopt["Min"][0]); ps[0].setMax(onelab::parameter::maxNumber());
   }
-  else if(fopt.count("Max")){
+  else if(noRange && fopt.count("Max")){
     ps[0].setMax(fopt["Max"][0]); ps[0].setMin(-onelab::parameter::maxNumber());
   }
-  if(fopt.count("Step")) ps[0].setStep(fopt["Step"][0]);
-  if(fopt.count("Choices")) ps[0].setChoices(fopt["Choices"]);
+  if(noRange && fopt.count("Step")) ps[0].setStep(fopt["Step"][0]);
+  if(noChoices && fopt.count("Choices")) ps[0].setChoices(fopt["Choices"]);
   if(fopt.count("Visible")) ps[0].setVisible(fopt["Visible"][0] ? true : false);
   if(copt.count("Help")) ps[0].setHelp(copt["Help"][0]);
   if(copt.count("Label")) ps[0].setLabel(copt["Label"][0]);
   if(copt.count("ShortHelp")) ps[0].setLabel(copt["ShortHelp"][0]);
-  if(copt.count("Loop")) ps[0].setAttribute("Loop", copt["Loop"][0]);
-  if(copt.count("Graph")) ps[0].setAttribute("Graph", copt["Graph"][0]);
+  if(noLoop && copt.count("Loop")) ps[0].setAttribute("Loop", copt["Loop"][0]);
+  if(noGraph && copt.count("Graph")) ps[0].setAttribute("Graph", copt["Graph"][0]);
   if(copt.count("Hightlight")) ps[0].setAttribute("Highlight", copt["Hightlight"][0]);
   _onelabClient->set(ps[0]);
 #endif
-- 
GitLab