Salome HOME
Issue #2063 crash during trim: it was corrected with #2065 issue, TestTrimLine02...
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetSelector.cpp
index 7e0eb3f0f80fd7985baa43b28af771873f02445a..11811c4220061e53355709ed179bf44471f4fd49 100755 (executable)
@@ -19,6 +19,8 @@
 
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeSelectionList.h>
 
 #include <TopoDS_Iterator.hxx>
 
@@ -58,7 +60,7 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
 //********************************************************************
 void ModuleBase_WidgetSelector::updateOnSelectionChanged(const bool theDone)
 {
-  // "false" flag should be used here, it connects to the #26658 OCC bug, when the user click in 
+  // "false" flag should be used here, it connects to the #26658 OCC bug, when the user click in
   // the same place repeatedly without mouse moved. In the case validation by filters is not
   // perfromed, so an invalid object is selected. E.g. distance constraint, selection of a point.
   // the 3rd click in the same point allow using this point.
@@ -78,7 +80,8 @@ void ModuleBase_WidgetSelector::updateOnSelectionChanged(const bool theDone)
 QIntList ModuleBase_WidgetSelector::getShapeTypes() const
 {
   QIntList aShapeTypes = shapeTypes();
-  if (/*aShapeTypes.contains(TopAbs_SOLID) ||*/ // this type should be mentioned in XML, poor selection otherwise
+  // this type should be mentioned in XML, poor selection otherwise
+  if (/*aShapeTypes.contains(TopAbs_SOLID) ||*/
       aShapeTypes.contains(ModuleBase_ResultPrs::Sel_Result/*TopAbs_SHAPE*/)) {
     // it should be selectable for both, "solids" and "objects" types
     aShapeTypes.append(TopAbs_COMPSOLID);
@@ -162,7 +165,7 @@ void ModuleBase_WidgetSelector::activateCustom()
 {
   connect(myWorkshop, SIGNAL(selectionChanged()), this,
           SLOT(onSelectionChanged()), Qt::UniqueConnection);
-  
+
   activateSelectionAndFilters(true);
 
   // Restore selection in the viewer by the attribute selection list
@@ -195,7 +198,8 @@ bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrsPtr
   getGeomSelection(thePrs, anObject, aShape);
 
   // the last flag is to be depending on hasObject is called before. To be corrected later
-  return ModuleBase_Tools::setObject(attribute(), anObject, aShape, myWorkshop, myIsInValidate, true);
+  return ModuleBase_Tools::setObject(attribute(), anObject, aShape,
+                                     myWorkshop, myIsInValidate, true);
 }
 
 //********************************************************************
@@ -204,7 +208,22 @@ void ModuleBase_WidgetSelector::deactivate()
   ModuleBase_ModelWidget::deactivate();
   disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
   activateSelectionAndFilters(false);
-  ModuleBase_ModelWidget::deactivate();
+
+  /// clear temporary cash
+  AttributePtr anAttribute = attribute();
+  if (!anAttribute.get())
+    return;
+  std::string aType = anAttribute->attributeType();
+  if (anAttribute->attributeType() == ModelAPI_AttributeSelection::typeId()) {
+    AttributeSelectionPtr aSelectAttr =
+                             std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
+    aSelectAttr->removeTemporaryValues();
+  }
+  else if (anAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectAttr =
+                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
+    aSelectAttr->removeTemporaryValues();
+  }
 }
 
 //********************************************************************