From f223914581860ceea7ed204bf1cfaaad29c3bf12 Mon Sep 17 00:00:00 2001 From: ganovelli Date: Thu, 4 Jun 2009 16:13:21 +0000 Subject: [PATCH] factorized a bit the attribute classes in TriMesh; added to IsValidHandle the check that pointer to data is not null. Explanation: a handle may be not valid for two reasons: 1) the attribute has been destroyed with a DeletePer*Attribute 2) the handle has been declared but not initialized. The change is to cover the case 2) --- vcg/complex/trimesh/allocate.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vcg/complex/trimesh/allocate.h b/vcg/complex/trimesh/allocate.h index dc3a2865..fab376d6 100644 --- a/vcg/complex/trimesh/allocate.h +++ b/vcg/complex/trimesh/allocate.h @@ -706,7 +706,7 @@ public: template static bool IsValidHandle( MeshType & m, const typename MeshType::template PerVertexAttributeHandle & a){ - + if(a._handle == NULL) return false; for(HandlesIterator i = m.vert_attr.begin(); i!=m.vert_attr.end();++i) if ( (*i).n_attr == a.n_attr ) return true; return false; @@ -779,6 +779,7 @@ public: template static bool IsValidHandle( MeshType & m, const typename MeshType::template PerEdgeAttributeHandle & a){ + if(a._handle == NULL) return false; for(HandlesIterator i = m.edge_attr.begin(); i!=m.edge_attr.end();++i) if ( (*i).n_attr == a.n_attr ) return true; return false; @@ -851,6 +852,7 @@ public: template static bool IsValidHandle( MeshType & m, const typename MeshType::template PerFaceAttributeHandle & a){ + if(a._handle == NULL) return false; for(HandlesIterator i = m.face_attr.begin(); i!=m.face_attr.end();++i) if ( (*i).n_attr == a.n_attr ) return true; return false; @@ -923,6 +925,7 @@ public: template static bool IsValidHandle( MeshType & m, const typename MeshType::template PerMeshAttributeHandle & a){ + if(a._handle == NULL) return false; for(HandlesIterator i = m.mesh_attr.begin(); i!=m.mesh_attr.end();++i) if ( (*i).n_attr == a.n_attr ) return true; return false;