Salome HOME
Task #3231: Sketcher Offset of a curve
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Validators.cpp
index beaef63a756a840074cafa3c52796798444b1d03..4ddedd5198f6bf2ac46d831ae6f1949d24b0e9b0 100644 (file)
@@ -519,6 +519,7 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute,
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
   AttributeRefListPtr aSelAttr =
     std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+  std::set<ObjectPtr> aSelected;
 
   AttributeRefListPtr aRefListOfInitial = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
       aFeature->attribute(SketchPlugin_Constraint::ENTITY_A()));
@@ -530,6 +531,12 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute,
   std::list<ObjectPtr>::iterator anObjIter;
   for(int anInd = 0; anInd < aSelAttr->size(); anInd++) {
     ObjectPtr aSelObject = aSelAttr->object(anInd);
+    if (aSelected.find(aSelObject) != aSelected.end()) {
+      theError = "Error: An object selected twice";
+      return false;
+    }
+    aSelected.insert(aSelObject);
+
     anObjIter = anInitialObjects.begin();
     for (; anObjIter != anInitialObjects.end(); anObjIter++)
       if (aSelObject == *anObjIter)