myNestedNum = 0;
myDoc->InitDeltaCompaction();
}
- myIsEmptyTr[myTransactionsAfterSave] = false;
+ myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand();
myTransactionsAfterSave++;
- myDoc->NewCommand();
+ myDoc->OpenCommand();
} else { // start the simple command
myDoc->NewCommand();
}
subDoc(*aSubIter)->startOperation();
}
-void Model_Document::compactNested()
+bool Model_Document::compactNested()
{
bool allWasEmpty = true;
while (myNestedNum != -1) {
myIsEmptyTr[myTransactionsAfterSave] = allWasEmpty;
myTransactionsAfterSave++;
myDoc->PerformDeltaCompaction();
+ return !allWasEmpty;
}
void Model_Document::finishOperation()
{
if (myNestedNum > 0 && !myDoc->HasOpenCommand()) { // abort all what was done in nested
// first compact all nested
- compactNested();
- // for nested it is undo and clear redos
- myDoc->Undo();
+ if (compactNested()) {
+ // for nested it is undo and clear redos
+ myDoc->Undo();
+ }
myDoc->ClearRedos();
myTransactionsAfterSave--;
myIsEmptyTr.erase(myTransactionsAfterSave);
return myDoc;
}
- //! performas compactification of all nested operations into one
- void compactNested();
+ //! performs compactification of all nested operations into one
+ //! \returns true if resulting transaction is not empty and can be undoed
+ bool compactNested();
//! Initializes the data fields of the feature
void initData(ObjectPtr theObj, TDF_Label theLab, const int theTag);
void ModelAPI_Feature::eraseResults()
{
- std::list<boost::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
- for(; aResIter != myResults.end(); aResIter++) {
- (*aResIter)->data()->erase();
- static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
- ModelAPI_EventCreator::get()->sendDeleted(document(), (*aResIter)->groupName());
+ if (!myResults.empty()) {
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
+ std::list<boost::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
+ for(; aResIter != myResults.end(); aResIter++) {
+ (*aResIter)->data()->erase();
+ ModelAPI_EventCreator::get()->sendDeleted(document(), (*aResIter)->groupName());
+ }
+ myResults.clear();
+ // flush it to avoid left presentations after input of invalid arguments (radius=0)
+ Events_Loop::loop()->flush(anEvent);
}
- myResults.clear();
}
boost::shared_ptr<ModelAPI_Document> ModelAPI_Feature::documentToAdd()