Salome HOME
Porting to OCCT 7.5.0 and minor improvements/bugfixes.
[modules/shaper.git] / src / Model / Model_Document.cpp
index 6046533abec17ecd956ea1e49f5269207f891782..03d5a423b26afd5d08b3d1132dfd454f10ab18cd 100644 (file)
@@ -317,6 +317,8 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum
   std::shared_ptr<Model_Session> aSession =
     std::dynamic_pointer_cast<Model_Session>(Model_Session::get());
   if (isOk) {
+    // keep handle to avoid destruction of the document until myObjs works on it
+    Handle(TDocStd_Document) anOldDoc = myDoc;
     myDoc = aLoaded;
     myDoc->SetUndoLimit(UNDO_LIMIT);
 
@@ -325,6 +327,7 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum
     aSession->setCheckTransactions(false);
     if (myObjs)
       delete myObjs;
+    anOldDoc.Nullify();
     myObjs = new Model_Objects(myDoc->Main()); // synchronization is inside
     myObjs->setOwner(theThis);
     // update the current features status
@@ -2309,6 +2312,8 @@ void Model_Document::appendTransactionToPrevious()
 {
   Transaction anAppended =  myTransactions.back();
   myTransactions.pop_back();
+  if (!myNestedNum.empty())
+    (*myNestedNum.rbegin())--;
   if (!myTransactions.empty()) { // if it is empty, just forget the appended
     myTransactions.back().myOCAFNum += anAppended.myOCAFNum;
   }