X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeRefAttrList.cpp;h=24e3462e811d2df31f2853bf3d56361cea4fc06b;hb=3803f064ab0c38ba6ae084921fd555a50310bcdb;hp=db780eac7da4aa4477ff09c591ac2eceaeb68947;hpb=6e421e939851e0de46554ae45a3ca0e1f67cd91d;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeRefAttrList.cpp b/src/Model/Model_AttributeRefAttrList.cpp index db780eac7..24e3462e8 100644 --- a/src/Model/Model_AttributeRefAttrList.cpp +++ b/src/Model/Model_AttributeRefAttrList.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -27,8 +27,13 @@ void Model_AttributeRefAttrList::append(ObjectPtr theObject) { - std::shared_ptr aData = std::dynamic_pointer_cast(theObject->data()); - myRef->Append(aData->label().Father()); // store label of the object + TDF_Label aLabel; + if (theObject) { + std::shared_ptr aData = std::dynamic_pointer_cast(theObject->data()); + aLabel = aData->label().Father(); + } + + myRef->Append(aLabel); // store label of the object myIDs->Append(""); // for the object store an empty string // do it before the transaction finish to make just created/removed objects know dependencies // and reference from composite feature is removed automatically @@ -306,7 +311,9 @@ void Model_AttributeRefAttrList::remove(const std::set& theIndices) myIDs->Append(anIDIter.Value()); } else { // found, so need to update the dependencies aOneisDeleted = true; - ObjectPtr anObj = aDoc->objects()->object(aRefIter.Value()); + ObjectPtr anObj; + if (!aRefIter.Value().IsNull()) + anObj = aDoc->objects()->object(aRefIter.Value()); if (anObj.get()) { REMOVE_BACK_REF(anObj); }