]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for issue #136 : set null active document when all documents are closing
authormpv <mpv@opencascade.com>
Thu, 29 Jan 2015 14:36:35 +0000 (17:36 +0300)
committermpv <mpv@opencascade.com>
Thu, 29 Jan 2015 14:36:35 +0000 (17:36 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Session.cpp

index 680b7fd3ed6354db2a17bb0ae5a97d30213f1648..2499f0366272ae454b0d4c83f9be503a46a30d95 100644 (file)
@@ -242,6 +242,9 @@ void Model_Document::close(const bool theForever)
   std::shared_ptr<ModelAPI_Session> aPM = Model_Session::get();
   if (this != aPM->moduleDocument().get() && this == aPM->activeDocument().get()) {
     aPM->setActiveDocument(aPM->moduleDocument());
+  } else if (this == aPM->moduleDocument().get()) {
+    // erase the active document if root is closed
+    aPM->setActiveDocument(DocumentPtr());
   }
   // close all subs
   const std::set<std::string> aSubs = subDocuments(true);
index 9f1783fe7b0fb5cd5ea532d53830997d18453ce9..816b87f750d1e391f44a92ef939a0981d5214289 100644 (file)
@@ -187,10 +187,10 @@ void Model_Session::setActiveDocument(
 {
   if (myCurrentDoc != theDoc) {
     myCurrentDoc = theDoc;
-    if (theSendSignal) {
+    if (theDoc.get() && 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) {
+      if (aDoc.get()) {
         bool aWasChecked = myCheckTransactions;
         setCheckTransactions(false);
         aDoc->synchronizeFeatures(false, true);