From: mpv Date: Wed, 27 May 2015 08:47:07 +0000 (+0300) Subject: Make second open notcrashed in this vearion X-Git-Tag: V_1.2.0~61 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=baa32d4d231be0ed859fc32f1736afcbcfaa1f73;p=modules%2Fshaper.git Make second open notcrashed in this vearion --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index a554fd599..3a341a5ac 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -257,8 +257,11 @@ void Model_Document::close(const bool theForever) // close all subs const std::set aSubs = subDocuments(true); std::set::iterator aSubIter = aSubs.begin(); - for (; aSubIter != aSubs.end(); aSubIter++) - subDoc(*aSubIter)->close(theForever); + for (; aSubIter != aSubs.end(); aSubIter++) { + std::shared_ptr aSub = subDoc(*aSubIter); + if (aSub->myObjs) // if it was not closed before + aSub->close(theForever); + } // close for thid document needs no transaction in this document std::static_pointer_cast(Model_Session::get())->setCheckTransactions(false); @@ -423,9 +426,14 @@ bool Model_Document::canUndo() // check other subs contains operation that can be undoed const std::set aSubs = subDocuments(true); std::set::iterator aSubIter = aSubs.begin(); - for (; aSubIter != aSubs.end(); aSubIter++) - if (subDoc(*aSubIter)->canUndo()) - return true; + for (; aSubIter != aSubs.end(); aSubIter++) { + std::shared_ptr aSub = subDoc(*aSubIter); + if (aSub->myObjs) {// if it was not closed before + if (aSub->canUndo()) + return true; + } + } + return false; } @@ -444,8 +452,11 @@ void Model_Document::undoInternal(const bool theWithSubs, const bool theSynchron // undo for all subs const std::set aSubs = subDocuments(true); std::set::iterator aSubIter = aSubs.begin(); - for (; aSubIter != aSubs.end(); aSubIter++) + for (; aSubIter != aSubs.end(); aSubIter++) { + if (!subDoc(*aSubIter)->myObjs) + continue; subDoc(*aSubIter)->undoInternal(theWithSubs, theSynchronize); + } } // after redo of all sub-documents to avoid updates on not-modified data (issue 370) if (theSynchronize) { @@ -467,9 +478,12 @@ bool Model_Document::canRedo() // check other subs contains operation that can be redoed const std::set aSubs = subDocuments(true); std::set::iterator aSubIter = aSubs.begin(); - for (; aSubIter != aSubs.end(); aSubIter++) + for (; aSubIter != aSubs.end(); aSubIter++) { + if (!subDoc(*aSubIter)->myObjs) + continue; if (subDoc(*aSubIter)->canRedo()) return true; + } return false; } @@ -677,7 +691,7 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr } if (theCurrent.get()) { std::shared_ptr aData = std::static_pointer_cast(theCurrent->data()); - if (!aData.get()) return; // unknown case + if (!aData.get() || !aData->isValid()) return; TDF_Label aFeatureLabel = aData->label().Father(); Handle(TDF_Reference) aRef; @@ -717,10 +731,10 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr void Model_Document::setCurrentFeatureUp() { - FeaturePtr aCurrent = currentFeature(false); + FeaturePtr aCurrent = currentFeature(true); if (aCurrent.get()) { // if not, do nothing because null is the upper FeaturePtr aPrev = myObjs->nextFeature(aCurrent, true); - setCurrentFeature(aPrev, false); + setCurrentFeature(aPrev, true); } } diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 08a7d4097..765ff1582 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -191,6 +191,8 @@ void Model_Update::updateInDoc(std::shared_ptr theDoc) if (!anObjs) return; FeaturePtr aFeatureIter = anObjs->firstFeature(); for (; aFeatureIter.get(); aFeatureIter = anObjs->nextFeature(aFeatureIter)) { + if (!aFeatureIter->data()->isValid()) // this may be on close of the document + continue; if (aFeatureIter && alreadyProcessed.find(aFeatureIter) == alreadyProcessed.end()) { // update selection and parameters attributes first, before sub-features analysis (sketch plane) updateArguments(aFeatureIter);