Salome HOME
Issue #2079 : Select parent feature for default Constructions. Disable popup menu...
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetSelector.cpp
index fda60cc0ea2030903ce8aa1ba33688a20ce6f9ad..11811c4220061e53355709ed179bf44471f4fd49 100755 (executable)
@@ -60,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.
@@ -80,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);
@@ -164,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
@@ -197,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);
 }
 
 //********************************************************************
@@ -209,6 +211,8 @@ void ModuleBase_WidgetSelector::deactivate()
 
   /// clear temporary cash
   AttributePtr anAttribute = attribute();
+  if (!anAttribute.get())
+    return;
   std::string aType = anAttribute->attributeType();
   if (anAttribute->attributeType() == ModelAPI_AttributeSelection::typeId()) {
     AttributeSelectionPtr aSelectAttr =
@@ -217,7 +221,7 @@ void ModuleBase_WidgetSelector::deactivate()
   }
   else if (anAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) {
     AttributeSelectionListPtr aSelectAttr =
-                             std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
+                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
     aSelectAttr->removeTemporaryValues();
   }
 }