From e0982cb7a97874070e00a25c7c4c0faf1716afc2 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 6 Nov 2014 18:50:26 +0300 Subject: [PATCH] Make the concealed bodies also concealed on open --- src/Config/Config_FeatureReader.cpp | 11 +++++++---- src/Model/Model_Session.cpp | 17 ++++++++++++++++- src/Model/Model_Validator.cpp | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 91e59df39..947fdb8ab 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -62,10 +62,13 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) } else if (myIsProcessWidgets && isWidgetNode(theNode)) { boost::shared_ptr aMessage(new Config_AttributeMessage(aMenuItemEvent, this)); aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID)); - aMessage->setAttributeId(getProperty(theNode, _ID)); - aMessage->setObligatory(getBooleanAttribute(theNode, ATTRIBUTE_OBLIGATORY, true)); - aMessage->setConcealment(getBooleanAttribute(theNode, ATTRIBUTE_CONCEALMENT, false)); - Events_Loop::loop()->send(aMessage); + std::string anAttributeID = getProperty(theNode, _ID); + if (!anAttributeID.empty()) { + aMessage->setAttributeId(anAttributeID); + aMessage->setObligatory(getBooleanAttribute(theNode, ATTRIBUTE_OBLIGATORY, true)); + aMessage->setConcealment(getBooleanAttribute(theNode, ATTRIBUTE_CONCEALMENT, false)); + Events_Loop::loop()->send(aMessage); + } } //Process SOURCE, VALIDATOR nodes. Config_XMLReader::processNode(theNode); diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index e3d811d0b..23e7a2621 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -94,7 +95,6 @@ FeaturePtr Model_Session::createFeature(string theFeatureID) if (this != myImpl) return myImpl->createFeature(theFeatureID); - LoadPluginsInfo(); if (myPlugins.find(theFeatureID) != myPlugins.end()) { std::pair& aPlugin = myPlugins[theFeatureID]; // plugin and doc kind if (!aPlugin.second.empty() && aPlugin.second != activeDocument()->kind()) { @@ -211,6 +211,9 @@ Model_Session::Model_Session() aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED), 0, true); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED), 0, true); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_VALIDATOR_LOADED)); + + // load all information about plugins, features and attributes + LoadPluginsInfo(); } void Model_Session::processEvent(const boost::shared_ptr& theMessage) @@ -226,6 +229,18 @@ void Model_Session::processEvent(const boost::shared_ptr& theMes myPlugins[aMsg->id()] = std::pair( aMsg->pluginLibrary(), aMsg->documentKind()); } + } else { + const boost::shared_ptr aMsgAttr = + boost::dynamic_pointer_cast(theMessage); + if (aMsgAttr) { + if (!aMsgAttr->isObligatory()) { + validators()->registerNotObligatory(aMsgAttr->featureId(), aMsgAttr->attributeId()); + } + if(aMsgAttr->isConcealment()) { + validators()->registerConcealment(aMsgAttr->featureId(), aMsgAttr->attributeId()); + } + + } } // plugins information was started to load, so, it will be loaded myPluginsInfoLoaded = true; diff --git a/src/Model/Model_Validator.cpp b/src/Model/Model_Validator.cpp index eecd08b33..9db3a3cba 100644 --- a/src/Model/Model_Validator.cpp +++ b/src/Model/Model_Validator.cpp @@ -176,7 +176,7 @@ bool Model_ValidatorsFactory::validate(const boost::shared_ptr } // check all attributes for validity boost::shared_ptr aData = theFeature->data(); - if (!aData->isValid()) + if (!aData || !aData->isValid()) return false; static const std::string kAllTypes = ""; std::map >::const_iterator aFeatureIter = -- 2.39.2