From 92eec412a5c37fdd03b4450c1e38a5816c024826 Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia Date: Thu, 28 Jul 2016 12:32:13 +0200 Subject: [PATCH] - the DeletePerMeshAttribute signature (and semantics...) has been consistent with the other DeletePerXXXAttribute functions I discussed with Fabio about it --- vcg/complex/allocate.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index 81da27ef..a664868e 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -1516,13 +1516,18 @@ public: return;} } - static void DeletePerMeshAttribute( MeshType & m, std::string name){ + // Generic DeleteAttribute. + // It must not crash if you try to delete a non existing attribute, + // because you do not have a way of asking for a handle of an attribute for which you do not know the type. + static bool DeletePerMeshAttribute( MeshType & m, std::string name){ AttrIterator i; PointerToAttribute h1; h1._name = name; i = m.mesh_attr.find(h1); - assert(i!=m.mesh_attr.end()); + if (i==m.mesh_attr.end()) + return false; delete ((SimpleTempDataBase *)(*i)._handle); m.mesh_attr.erase(i); + return true; } template