From: mpv Date: Fri, 16 Jan 2015 14:24:10 +0000 (+0300) Subject: Fix for issue #347 : on undo of part creation reset the current document X-Git-Tag: V_1.0.0~22^2~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=db0a4bd8104e025ac6dcf7a057e11e81655d876e;p=modules%2Fshaper.git Fix for issue #347 : on undo of part creation reset the current document --- diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 159b7a2f6..be2cb0621 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -233,7 +234,8 @@ Model_Session::Model_Session() ModelAPI_Session::setSession(std::shared_ptr(this)); // register the configuration reading listener Events_Loop* aLoop = Events_Loop::loop(); - static const Events_ID kFeatureEvent = Events_Loop::eventByName(Config_FeatureMessage::MODEL_EVENT()); + static const Events_ID kFeatureEvent = + Events_Loop::eventByName(Config_FeatureMessage::MODEL_EVENT()); aLoop->registerListener(this, kFeatureEvent); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED), 0, true); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED), 0, true); @@ -243,7 +245,8 @@ Model_Session::Model_Session() void Model_Session::processEvent(const std::shared_ptr& theMessage) { - static const Events_ID kFeatureEvent = Events_Loop::eventByName(Config_FeatureMessage::MODEL_EVENT()); + static const Events_ID kFeatureEvent = + Events_Loop::eventByName(Config_FeatureMessage::MODEL_EVENT()); static const Events_ID kValidatorEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED); if (theMessage->eventID() == kFeatureEvent) { const std::shared_ptr aMsg = @@ -283,6 +286,17 @@ void Model_Session::processEvent(const std::shared_ptr& theMessa } else { // create/update/delete if (myCheckTransactions && !isOperation()) Events_Error::send("Modification of data structure outside of the transaction"); + // if part is deleted, make the root as the current document (on undo of Parts creations) + static const Events_ID kDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED); + if (theMessage->eventID() == kDeletedEvent) { + std::shared_ptr aDeleted = + std::dynamic_pointer_cast(theMessage); + if (aDeleted && + aDeleted->groups().find(ModelAPI_ResultPart::group()) != aDeleted->groups().end()) + { + setActiveDocument(moduleDocument()); + } + } } }