Salome HOME
Issue #2481: Application error when create fillet
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_WidgetParamsMgr.cpp
index be7aa91ece6bcf2a70f2049ca7d00d06baa26d45..96e10edb14c720706a7f03058c5e5c9059301d4f 100644 (file)
@@ -1,8 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        ParametersPlugin_WidgetParamsMgr.cpp
-// Created:     11 Apr 2016
-// Author:      Vitaly SMETANNIKOV
+// 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 "ParametersPlugin_WidgetParamsMgr.h"
 #include "ParametersPlugin_Parameter.h"
@@ -297,7 +311,7 @@ void ParametersPlugin_WidgetParamsMgr::updateParametersFeatures()
   int aNbFeatures = aDoc->numInternalFeatures();
   for (int i = 0; i < aNbFeatures; i++) {
     aParamFeature = aDoc->internalFeature(i);
-    if (aParamFeature->getKind() == ParametersPlugin_Parameter::ID()) {
+    if (aParamFeature && aParamFeature->getKind() == ParametersPlugin_Parameter::ID()) {
       myParametersList.append(aParamFeature);
     }
   }
@@ -329,7 +343,7 @@ QList<QStringList> ParametersPlugin_WidgetParamsMgr::
     for(aIt = aRefs.cbegin(); aIt != aRefs.cend(); aIt++) {
       std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
       FeaturePtr aReferenced = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
-      if (aReferenced.get()) {
+      if (aReferenced.get() && (aReferenced != aParameter)) {
         if (aReferenced->getKind() == ParametersPlugin_Parameter::ID()) {
           // Find referenced feature Recursive
           QList<FeaturePtr> aList;
@@ -758,16 +772,14 @@ void ParametersPlugin_WidgetParamsMgr::enableButtons(bool theEnable)
 bool ParametersPlugin_WidgetParamsMgr::isValid()
 {
   QTreeWidgetItem* aItem;
-  bool aIsValid = true;
   for(int i = 0; i < myParameters->childCount(); i++) {
     aItem = myParameters->child(i);
     if ((aItem->text(Col_Name) == NoName) ||
         (aItem->text(Col_Equation) == NoValue) ||
         (!ModelAPI_Expression::isVariable(aItem->text(Col_Name).toStdString())) ) {
-      aIsValid = false;
-      break;
+      return false;
     }
   }
-  return aIsValid;
+  return true;
 }