From e663fb9bacf4879bdc05014f66eeb948478b86e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20M=C3=B6ller?= Date: Tue, 28 Jul 2015 18:16:16 +0000 Subject: [PATCH] fix crash when saving a mesh and a custom property was removed before extend unittest for this case git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1323 fdac6126-5c0c-442c-9429-916003d36597 --- src/OpenMesh/Core/IO/writer/PLYWriter.cc | 2 +- src/Unittests/unittests_read_write_PLY.cc | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/IO/writer/PLYWriter.cc b/src/OpenMesh/Core/IO/writer/PLYWriter.cc index 6108b0c6..49186c90 100644 --- a/src/OpenMesh/Core/IO/writer/PLYWriter.cc +++ b/src/OpenMesh/Core/IO/writer/PLYWriter.cc @@ -207,7 +207,7 @@ std::vector<_PLYWriter_::CustomProperty> _PLYWriter_::writeCustomTypeHeader(std: // check, if property is persistant - if (!prop->persistent()) + if (!prop || !prop->persistent()) continue; diff --git a/src/Unittests/unittests_read_write_PLY.cc b/src/Unittests/unittests_read_write_PLY.cc index 9cffffa8..d7a27fe2 100644 --- a/src/Unittests/unittests_read_write_PLY.cc +++ b/src/Unittests/unittests_read_write_PLY.cc @@ -538,20 +538,24 @@ TEST_F(OpenMeshReadWritePLY, WriteReadSimplePLYWithCustomProps) { OpenMesh::VPropHandleT nonPersistant; OpenMesh::VPropHandleT qualityProp; OpenMesh::FPropHandleT faceProp; + OpenMesh::VPropHandleT removedProp; const std::string indexPropName = "mySuperIndexProperty"; const std::string qualityPropName = "quality"; const std::string facePropName = "anotherPropForFaces"; const std::string nonPersistantName = "nonPersistant"; + const std::string removedPropName = "willBeRemoved"; mesh.add_property(indexProp,indexPropName); mesh.add_property(qualityProp,qualityPropName); + mesh.add_property(removedProp, removedPropName); mesh.add_property(faceProp,facePropName); mesh.add_property(nonPersistant,nonPersistantName); mesh.property(indexProp).set_persistent(true); mesh.property(qualityProp).set_persistent(true); mesh.property(faceProp).set_persistent(true); + mesh.remove_property(removedProp); signed char i=0; for (Mesh::VertexIter v_iter = mesh.vertices_begin(); v_iter != mesh.vertices_end(); ++v_iter, ++i)