From: mpv Date: Tue, 26 May 2015 07:33:49 +0000 (+0300) Subject: Make Data not null, but invalid after the feature remove X-Git-Tag: V_1.2.0~88 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b2ab6b5d1fb5d1da1e04d68298605660cf5cce24;p=modules%2Fshaper.git Make Data not null, but invalid after the feature remove --- diff --git a/src/Model/Model_AttributeReference.cpp b/src/Model/Model_AttributeReference.cpp index a6ac5e31a..700e2f7d3 100644 --- a/src/Model/Model_AttributeReference.cpp +++ b/src/Model/Model_AttributeReference.cpp @@ -28,7 +28,7 @@ void Model_AttributeReference::setValue(ObjectPtr theObject) REMOVE_BACK_REF(aValue); TDF_Label anObjLab; - if (theObject.get() && theObject->data().get() && theObject->data()->isValid()) { + if (theObject.get() && theObject->data()->isValid()) { std::shared_ptr aData = std::dynamic_pointer_cast( theObject->data()); anObjLab = aData->label().Father(); // object label diff --git a/src/Model/Model_FeatureValidator.cpp b/src/Model/Model_FeatureValidator.cpp index a809abe46..8cec7f4b7 100644 --- a/src/Model/Model_FeatureValidator.cpp +++ b/src/Model/Model_FeatureValidator.cpp @@ -23,7 +23,7 @@ bool Model_FeatureValidator::isValid(const std::shared_ptr& th std::shared_ptr aData = theFeature->data(); // "Action" features has no data, but still valid. e.g "Remove Part" - if (!aData) { + if (!aData->isValid()) { return theFeature->isAction(); } if (!aData->isValid()) diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 6a2d435ff..17f344c28 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -145,7 +145,7 @@ void Model_Update::processOperation(const bool theTotalUpdate, const bool theFin for(aFIter = myJustCreated.begin(); aFIter != myJustCreated.end(); aFIter++) { FeaturePtr aF = std::dynamic_pointer_cast(*aFIter); - if (aF && aF->data().get() && aF->getKind() == "Extrusion") { + if (aF && aF->data()->isValid() && aF->getKind() == "Extrusion") { AttributeSelectionListPtr aBase = aF->selectionList("base"); if (aBase.get()) { for(int a = aBase->size() - 1; a >= 0; a--) { diff --git a/src/ModelAPI/ModelAPI_Object.cpp b/src/ModelAPI/ModelAPI_Object.cpp index bb3339f93..dc76a0792 100644 --- a/src/ModelAPI/ModelAPI_Object.cpp +++ b/src/ModelAPI/ModelAPI_Object.cpp @@ -12,7 +12,7 @@ bool ModelAPI_Object::isInHistory() { - if (myData.get() && myData->isValid()) { + if (myData->isValid()) { return myData->isInHistory(); } return true; // default value @@ -22,7 +22,7 @@ void ModelAPI_Object::setInHistory( const std::shared_ptr theObject, const bool theFlag) { if (isInHistory() != theFlag) { - if (myData.get() && myData->isValid()) { + if (myData->isValid()) { myData->setIsInHistory(theFlag); } myDoc->updateHistory(theObject); @@ -68,7 +68,7 @@ void ModelAPI_Object::setDoc(std::shared_ptr theDoc) void ModelAPI_Object::erase() { - if (myData.get() && myData != myData->invalidPtr()) myData->erase(); + if (myData->isValid() && myData != myData->invalidPtr()) myData->erase(); setData(myData->invalidPtr()); } diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index d688e90aa..8b5ed2d24 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -64,7 +64,7 @@ FeaturePtr ModuleBase_Operation::feature() const bool ModuleBase_Operation::isValid() const { - if (!myFeature || !myFeature->data().get()) + if (!myFeature || !myFeature->data()->isValid()) return true; // rename operation if (myFeature->isAction()) return true; diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 745497c8a..449dd2d3f 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -150,7 +150,7 @@ QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo) if (aFeature.get()) { aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str()); - if (aFeature->data().get() && aFeature->data()->isValid()) { + if (aFeature->data()->isValid()) { aFeatureStr.append(QString(", name=%1").arg(aFeature->data()->name().c_str()).toStdString() .c_str()); } diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 62e152f62..1441e2957 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -251,7 +251,7 @@ GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const { GeomShapePtr aShape; DataPtr aData = myFeature->data(); - if (aData.get() == NULL) + if (!aData->isValid()) return aShape; AttributeSelectionPtr aSelect = aData->selection(attributeID()); @@ -265,7 +265,7 @@ GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const void ModuleBase_WidgetShapeSelector::updateSelectionName() { DataPtr aData = myFeature->data(); - if (aData.get() == NULL) + if (!aData->isValid()) return; bool isNameUpdated = false; diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 9394b1a6b..339e26101 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -460,7 +460,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve continue; std::string aAttrId = anAttr->id(); DataPtr aData = aFeature->data(); - if (aData.get() != NULL) { + if (aData->isValid()) { std::shared_ptr aPoint = std::dynamic_pointer_cast(aData->attribute(aAttrId)); if (aPoint.get() != NULL) { @@ -723,7 +723,7 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) XGUI_ModuleConnector* aConnector = dynamic_cast(myModule->workshop()); DataPtr aData = myCurrentSketch->data(); - if ((!aData) || (!aData->isValid())) { + if (!aData->isValid()) { XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); // The sketch was aborted myCurrentSketch = CompositeFeaturePtr(); @@ -734,7 +734,7 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) QObjectPtrList aObjects = aDisplayer->displayedObjects(); foreach (ObjectPtr aObj, aObjects) { DataPtr aObjData = aObj->data(); - if ((!aObjData) || (!aObjData->isValid())) + if (!aObjData->isValid()) aObj->setDisplayed(false); } return; diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 55f0157b0..e31b1b2b5 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -264,7 +264,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr& theAttribute) const { std::list > > allRefs; - if (theAttribute->owner().get() && theAttribute->owner()->data().get()) + if (theAttribute->owner().get() && theAttribute->owner()->data()->isValid()) theAttribute->owner()->data()->referencesToObjects(allRefs); // collect object referenced by theAttribute std::list* anAttrObjs = 0; diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 2d02f0dd1..7b7fb78d0 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -137,7 +137,7 @@ std::shared_ptr SketchPlugin_Sketch::addFeature(std::string th void SketchPlugin_Sketch::removeFeature(std::shared_ptr theFeature) { - if (!data().get()) // sketch is already removed (case on undo of sketch), sync is not needed + if (!data()->isValid()) // sketch is already removed (case on undo of sketch), sync is not needed return; list aSubs = data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list(); list::iterator aSubIt = aSubs.begin(), aLastIt = aSubs.end(); diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 8e2aa58b6..ef725b563 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -341,7 +341,7 @@ std::shared_ptr SketchSolver_ConstraintManager continue; DataPtr aData = aWP->data(); - if (aData) { + if (aData->isValid()) { std::shared_ptr aWPFeatures = std::dynamic_pointer_cast< ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID())); std::list aFeaturesList = aWPFeatures->list(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index dcf348ff6..b7f68ebaa 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1267,7 +1267,7 @@ void XGUI_Workshop::deleteObjects() aDescription += tr(" %1"); QStringList aObjectNames; foreach (ObjectPtr aObj, anObjects) { - if (!aObj->data().get()) + if (!aObj->data()->isValid()) continue; aObjectNames << QString::fromStdString(aObj->data()->name()); }