From c4357fdc3c527083005eaaa03255ef7bf359175e Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 9 May 2014 14:25:05 +0000
Subject: [PATCH] better parameterSpace::setChanged(bool changed, client)
 behaviour: - if no client is given, set the changed flag for all the
 parameters; - if a client name is given and "changed" is false, affect only
 the  parameters that are owned exclusively by the client; - if "changed" is
 true, affect all parameters that depend on this client

---
 Common/onelab.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Common/onelab.h b/Common/onelab.h
index e8ef8cf228..5b43eac747 100644
--- a/Common/onelab.h
+++ b/Common/onelab.h
@@ -100,6 +100,7 @@ namespace onelab{
     {
       return (_clients.find(client) != _clients.end());
     }
+    int getNumClients() { return (int)_clients.size(); };
     virtual std::string getType() const = 0;
     const std::string &getName() const { return _name; }
     const std::string &getLabel() const { return _label; }
@@ -769,15 +770,17 @@ namespace onelab{
       }
       return false;
     }
-    // set the changed flag for all parameters (optionnally only affect those
-    // parameters that depend on a given client)
+    // if no client name is given, set the changed flag for all the parameters;
+    // if a client name is given and "changed" is false, affect only the
+    // parameters that are owned exclusively by the client; if "changed" is
+    // true, affect all parameters that depend on this client
     bool setChanged(bool changed, const std::string &client="")
     {
       std::set<parameter*, parameterLessThan> ps;
       _getAllParameters(ps);
       for(std::set<parameter*, parameterLessThan>::iterator it = ps.begin();
           it != ps.end(); it++)
-        if(client.empty() || (*it)->hasClient(client))
+        if(client.empty() || ((*it)->hasClient(client) && (changed || (*it)->getNumClients() == 1)))
           (*it)->setChanged(changed);
       return true;
     }
-- 
GitLab