From: mpv Date: Thu, 29 Jan 2015 14:36:35 +0000 (+0300) Subject: Fix for issue #136 : set null active document when all documents are closing X-Git-Tag: V_1.0.0~13^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d48846b153374196a5cddae842e06ba2ff98d12a;p=modules%2Fshaper.git Fix for issue #136 : set null active document when all documents are closing --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 680b7fd3e..2499f0366 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -242,6 +242,9 @@ void Model_Document::close(const bool theForever) std::shared_ptr 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 aSubs = subDocuments(true); diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 9f1783fe7..816b87f75 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -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 aDoc = std::dynamic_pointer_cast(theDoc); - if (aDoc) { + if (aDoc.get()) { bool aWasChecked = myCheckTransactions; setCheckTransactions(false); aDoc->synchronizeFeatures(false, true);