Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_EvalListener.cpp
index 428f43f8bee2c32da2266bdd0a18861041698176..cc299083317be073bda56b3ab5da4bda2d24feca 100644 (file)
@@ -1,10 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-/*
- * ParametersPlugin_EvalListener.cpp
- *
- *  Created on: Apr 28, 2015
- *      Author: sbh
- */
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include <pyconfig.h>
 
@@ -20,6 +32,7 @@
 #include <ModelAPI_AttributeValidator.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
 
@@ -140,9 +153,9 @@ void ParametersPlugin_EvalListener::renameInParameter(
                                                 theNewName);
   // Issue #588. No need for reevaluating expression.
   // Moreover, current history may not contain necessary parameters.
-  anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(true);
+  bool aWasBlocked = anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(true);
   anExpressionAttribute->setValue(anExpressionString);
-  anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(false);
+  anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(aWasBlocked);
 }
 
 void ParametersPlugin_EvalListener::renameInAttribute(
@@ -229,18 +242,19 @@ bool isValidAttribute(const AttributePtr& theAttribute)
 
 void setParameterName(ResultParameterPtr theResultParameter, const std::string& theName)
 {
-  theResultParameter->data()->blockSendAttributeUpdated(true);
+  bool aWasBlocked = theResultParameter->data()->blockSendAttributeUpdated(true);
   theResultParameter->data()->setName(theName);
-  theResultParameter->data()->blockSendAttributeUpdated(false, false);
+  theResultParameter->data()->blockSendAttributeUpdated(aWasBlocked, false);
 
   std::shared_ptr<ParametersPlugin_Parameter> aParameter =
       std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
           ModelAPI_Feature::feature(theResultParameter));
 
-  aParameter->data()->blockSendAttributeUpdated(true);
+  std::string anOldName = aParameter->name();
+  aWasBlocked = aParameter->data()->blockSendAttributeUpdated(true);
   aParameter->data()->setName(theName);
   aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID())->setValue(theName);
-  aParameter->data()->blockSendAttributeUpdated(false);
+  aParameter->data()->blockSendAttributeUpdated(aWasBlocked);
 }
 
 void ParametersPlugin_EvalListener::processObjectRenamedEvent(