From dc19b4c930a9c2cf5db509fc81586deab00e7417 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 10 Sep 2015 19:35:08 +0300 Subject: [PATCH] Fix for the issue #937 and crashes: --- src/Model/Model_Document.cpp | 3 +++ src/Model/Model_Objects.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 21f5f1aa4..d85fb7b29 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -68,6 +68,8 @@ Model_Document::Model_Document(const std::string theID, const std::string theKin // in transaction for nesting correct working myDoc->NewCommand(); TDataStd_Integer::Set(myDoc->Main().Father(), 0); + // this to avoid creation of integer attribute outside the transaction after undo + transactionID(); myDoc->CommitCommand(); } @@ -278,6 +280,7 @@ void Model_Document::close(const bool theForever) // close all only if it is really asked, otherwise it can be undoed/redoed if (theForever) { + // flush everything to avoid messages with bad objects delete myObjs; myObjs = 0; if (myDoc->CanClose() == CDM_CCS_OK) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 988b2eb87..b30356fff 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -79,6 +79,7 @@ Model_Objects::~Model_Objects() myFeatures.UnBind(aFeaturesIter.Key()); } aLoop->activateFlushes(isActive); + aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); @@ -611,6 +612,16 @@ void Model_Objects::synchronizeFeatures( aKeptFeatures.insert(aFeature); if (anUpdatedMap.Contains(aFeatureLabel)) { ModelAPI_EventCreator::get()->sendUpdated(aFeature, anUpdateEvent); + if (aFeature->getKind() == "Parameter") { // if parameters are changed, update the results (issue 937) + const std::list >& aResults = aFeature->results(); + std::list >::const_iterator aRIter = aResults.begin(); + for (; aRIter != aResults.cend(); aRIter++) { + std::shared_ptr aRes = *aRIter; + if (aRes->data()->isValid() && !aRes->isDisabled()) { + ModelAPI_EventCreator::get()->sendUpdated(aRes, anUpdateEvent); + } + } + } } } } -- 2.39.2