if (!isError) {
myDoc->SetUndoLimit(UNDO_LIMIT);
// to avoid the problem that feature is created in the current, not this, document
- Model_Session::get()->setActiveDocument(anApp->getDocument(myID), false);
+ std::shared_ptr<Model_Session> aSession =
+ std::dynamic_pointer_cast<Model_Session>(Model_Session::get());
+ aSession->setActiveDocument(anApp->getDocument(myID), false);
+ aSession->setCheckTransactions(false);
synchronizeFeatures(false, true);
- Model_Session::get()->setActiveDocument(Model_Session::get()->moduleDocument(), false);
- Model_Session::get()->setActiveDocument(anApp->getDocument(myID), true);
+ aSession->setCheckTransactions(true);
+ aSession->setActiveDocument(Model_Session::get()->moduleDocument(), false);
+ aSession->setActiveDocument(anApp->getDocument(myID), true);
}
return !isError;
}
subDoc(*aSubIter)->close(theForever);
// close for thid document needs no transaction in this document
- std::static_pointer_cast<Model_Session>(Model_Session::get())->setCheckTransactions(false);
+ if (this == aPM->moduleDocument().get())
+ std::static_pointer_cast<Model_Session>(Model_Session::get())->setCheckTransactions(false);
// delete all features of this document
std::shared_ptr<ModelAPI_Document> aThis =
myDoc->Close();
}
- std::static_pointer_cast<Model_Session>(Model_Session::get())->setCheckTransactions(true);
+ if (this == aPM->moduleDocument().get())
+ std::static_pointer_cast<Model_Session>(Model_Session::get())->setCheckTransactions(true);
}
void Model_Document::startOperation()
bool isNestedClosed = !myDoc->HasOpenCommand() && !myNestedNum.empty();
static std::shared_ptr<Model_Session> aSession =
std::static_pointer_cast<Model_Session>(Model_Session::get());
- // just to be sure that everybody knows that changes were performed
- if (isNestedClosed) {
- aSession->setCheckTransactions(false); // for nested transaction commit
- }
synchronizeBackRefs();
Events_Loop* aLoop = Events_Loop::loop();
aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
// to avoid "updated" message appearance by updater
//aLoop->clear(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- if (isNestedClosed) {
- aSession->setCheckTransactions(true); // for nested transaction commit
- }
-
// finish for all subs first: to avoid nested finishing and "isOperation" calls problems inside
const std::set<std::string> aSubs = subDocuments(true);
std::set<std::string>::iterator aSubIter = aSubs.begin();
std::shared_ptr<ModelAPI_Document> aThis =
Model_Application::getApplication()->getDocument(myID);
// after all updates, sends a message that groups of features were created or updated
- std::static_pointer_cast<Model_Session>(Model_Session::get())
- ->setCheckTransactions(false);
Events_Loop* aLoop = Events_Loop::loop();
aLoop->activateFlushes(false);
ModelAPI_EventCreator::get()->sendUpdated(aFeature, EVENT_DISP);
aFeature->erase();
// unbind after the "erase" call: on abort sketch is removes sub-objects that corrupts aFIter
- TDF_Label aLab = aFIter.Key();
- aFIter.Next();
- myObjs.UnBind(aLab);
+ myObjs.UnBind(aFIter.Key());
+ // reinitialize iterator because unbind may corrupt the previous order in the map
+ aFIter.Initialize(myObjs);
} else
aFIter.Next();
}
aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TOHIDE));
- std::static_pointer_cast<Model_Session>(Model_Session::get())
- ->setCheckTransactions(true);
myExecuteFeatures = true;
}
bool Model_Session::load(const char* theFileName)
{
- return ROOT_DOC->load(theFileName);
+ bool aRes = ROOT_DOC->load(theFileName);
+ return aRes;
}
bool Model_Session::save(const char* theFileName, std::list<std::string>& theResults)
void Model_Session::finishOperation()
{
+ setCheckTransactions(false);
ROOT_DOC->finishOperation();
+ setCheckTransactions(true);
}
void Model_Session::abortOperation()
{
+ setCheckTransactions(false);
ROOT_DOC->abortOperation();
+ setCheckTransactions(true);
// here the update mechanism may work after abort, so, supress the warnings about
// modifications outside of the transactions
bool aWasCheck = myCheckTransactions;
void Model_Session::undo()
{
+ setCheckTransactions(false);
ROOT_DOC->undo();
+ setCheckTransactions(true);
}
bool Model_Session::canRedo()
void Model_Session::redo()
{
+ setCheckTransactions(false);
ROOT_DOC->redo();
+ setCheckTransactions(true);
}
FeaturePtr Model_Session::createFeature(string theFeatureID)
if (myCurrentDoc != theDoc) {
myCurrentDoc = theDoc;
if (theSendSignal) {
+ // syncronize the document: it may be just opened or opened but removed before
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(theDoc);
+ if (aDoc) {
+ bool aWasChecked = myCheckTransactions;
+ setCheckTransactions(false);
+ aDoc->synchronizeFeatures(false, true);
+ if (aWasChecked)
+ setCheckTransactions(true);
+ }
static std::shared_ptr<Events_Message> aMsg(
new Events_Message(Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)));
Events_Loop::loop()->send(aMsg);