Salome HOME
[bos #29947] [CEA 29944] SIGSEGV using filet
[modules/shaper.git] / src / ModuleBase / ModuleBase_ModelWidget.cpp
index a563c277981ff7cf1ca87f8a0174cd535209eac2..a21cf4517902ce714da983ed57c2d26c2c22e4a2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  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
 ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
   const Config_WidgetAPI* theData)
   : QWidget(theParent),
-  myIsEditing(false),
+  myWidgetValidator(0),
   myState(Stored),
+  myIsEditing(false),
   myIsValueStateBlocked(false),
-  myFlushUpdateBlocked(false),
-  myWidgetValidator(0)
+  myFlushUpdateBlocked(false)
 {
 #ifdef DEBUG_WIDGET_INSTANCE
   qDebug("ModuleBase_ModelWidget::ModuleBase_ModelWidget");
@@ -65,6 +65,7 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
   myFeatureId = theData->featureId();
 
   myIsInternal = theData->getBooleanAttribute(ATTR_INTERNAL, false);
+  myUseExternalParts = theData->getBooleanAttribute("allow_parts_content", false);
 
   myIsModifiedInEdit = theData->getProperty(ATTR_MODIFIED_IN_EDIT);
 
@@ -190,7 +191,6 @@ QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const
   if (!feature().get())
     return anError;
 
-  std::string aFeatureID = feature()->getKind();
   std::string anAttributeID = attributeID();
   AttributePtr anAttribute = feature()->attribute(anAttributeID);
   if (!anAttribute.get())
@@ -205,7 +205,7 @@ QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const
       anErrorMsg = "Unknown error.";
 
     if (anErrorMsg.context().empty()) {
-      anErrorMsg.setContext(aFeatureID + ":" + anAttributeID + ":" + aValidatorID);
+      anErrorMsg.setContext(context() + ":" + aValidatorID);
     }
   }
 
@@ -425,6 +425,12 @@ bool ModuleBase_ModelWidget::blockValueState(const bool theBlocked)
 //**************************************************************
 bool ModuleBase_ModelWidget::restoreValue()
 {
+  if (!isEnabled()) {
+    // This code works in inspection panel
+    ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+    if (!aValidators->isCase(myFeature, attributeID()))
+      return false; // if it is not an active case for the widget
+  }
   emit beforeValuesRestored();
   bool isDone = restoreValueCustom();
   emit afterValuesRestored();