Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetShapeSelector.cpp
index 47045007066d2890123230111f8352465ea8efc1..bd5e54e707b51b445aeeaad5f50eb4cac305047b 100644 (file)
@@ -23,6 +23,7 @@
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultBody.h>
 #include <Config_WidgetAPI.h>
 #include <Events_Error.h>
 
@@ -46,8 +47,7 @@
 #include <boost/smart_ptr/shared_ptr.hpp>
 
 #include <list>
-#include <stdexcept>
-#include <xstring>
+#include <string>
 
 typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
 static ShapeTypes MyShapeTypes;
@@ -189,9 +189,16 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged()
       return;
     if (mySelectedObject && aObject && mySelectedObject->isSame(aObject))
       return;
+    // Check that the selected object is result (others can not be accepted)
+    ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+    if (!aRes)
+      return;
+    // Check that the result has a shape
+    GeomShapePtr aShape = ModelAPI_Tools::shape(aRes);
+    if (!aShape)
+      return;
 
     // Get sub-shapes from local selection
-    boost::shared_ptr<GeomAPI_Shape> aShape;
     if (myUseSubShapes) {
       NCollection_List<TopoDS_Shape> aShapeList;
       std::list<ObjectPtr> aOwners;
@@ -227,7 +234,6 @@ void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj, boost::shared_p
     if (!myUseSubShapes) {
       static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TOHIDE);
       ModelAPI_EventCreator::get()->sendUpdated(mySelectedObject, anEvent);
-      Events_Loop::loop()->flush(anEvent);
     }
   } 
   updateSelectionName();