std::list<ResultPtr>::const_iterator aResIter = theFeature->results().cbegin();
while(aResIter != theFeature->results().cend()) {
ResultPtr aBody = std::dynamic_pointer_cast<ModelAPI_Result>(*aResIter);
- if (aBody) {
+ if (aBody.get()) {
if (!aBody->data()->isValid()) {
// found a disappeared result => remove it
- theFeature->removeResult(aBody);
+ theFeature->eraseResultFromList(aBody);
// start iterate from beginning because iterator is corrupted by removing
aResIter = theFeature->results().cbegin();
continue;
aLoop->flush(aRedispEvent);
}
+void ModelAPI_Feature::eraseResultFromList(const std::shared_ptr<ModelAPI_Result>& theResult)
+{
+ std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
+ for(; aResIter != myResults.end(); aResIter++) {
+ ResultPtr aRes = *aResIter;
+ if (aRes == theResult) {
+ std::string aGroup = aRes->groupName();
+ aRes->data()->erase();
+ myResults.erase(aResIter);
+
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
+ ModelAPI_EventCreator::get()->sendDeleted(document(), aGroup);
+ aECreator->sendUpdated(aRes, EVENT_DISP);
+ break;
+ }
+ }
+}
+
void ModelAPI_Feature::removeResults(const int theSinceIndex, const bool theFlush)
{
std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
MODELAPI_EXPORT void eraseResults();
/// removes all fields from this feature: results, data, etc
MODELAPI_EXPORT virtual void erase();
+ /// removes the result from the list of feature (not doing in disabled): normally this
+ /// method is not used from features. only internally
+ MODELAPI_EXPORT void eraseResultFromList(const std::shared_ptr<ModelAPI_Result>& theResult);
/// Returns true if result is persistent (stored in document) and on undo-redo, save-open
/// it is not needed to recompute it.