- ModuleBase_WidgetMultiSelector::onSelectionChanged();
- // TODO(nds): unite with externalObject(), remove parameters
- //myFeature->execute();
-
- DataPtr aData = myFeature->data();
- AttributeSelectionListPtr aSelectionListAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
-
- QObjectPtrList aListOfAttributeObjects;
- for (int i = 0; i < aSelectionListAttr->size(); i++) {
- AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
- aListOfAttributeObjects.append(anAttr->context());
+ bool aSucceed = ModuleBase_WidgetMultiSelector::setSelection(theValues, theToValidate);
+ if (aSucceed) {
+ // TODO(nds): unite with externalObject(), remove parameters
+ //myFeature->execute();
+
+ QObjectPtrList aListOfAttributeObjects;
+
+ AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
+ if (anAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
+ for (int i = 0; i < aSelectionListAttr->size(); i++) {
+ AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
+ aListOfAttributeObjects.append(anAttr->context());
+ }
+ }
+ else if (anAttribute->attributeType() == ModelAPI_AttributeRefList::typeId()) {
+ AttributeRefListPtr aRefListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
+ for (int i = 0; i < aRefListAttr->size(); i++) {
+ aListOfAttributeObjects.append(aRefListAttr->object(i));
+ }
+ }
+
+ myExternalObjectMgr->removeUnusedExternalObjects(aListOfAttributeObjects, sketch(), myFeature);