From 1d043197b19afab0740c1cabd26818a5643ce2f3 Mon Sep 17 00:00:00 2001 From: Alexander Dielen Date: Wed, 13 Jan 2016 13:58:48 +0100 Subject: [PATCH] fixed dangling pointer --- src/Python/Decimater.hh | 22 ++++++++++++---------- src/Python/PropertyManager.hh | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Python/Decimater.hh b/src/Python/Decimater.hh index 5eb18e61..c0825231 100644 --- a/src/Python/Decimater.hh +++ b/src/Python/Decimater.hh @@ -19,6 +19,8 @@ namespace OpenMesh { namespace Python { +#define INIT_MESH_REF init()[with_custodian_and_ward<1,2>()] + BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(decimate_overloads, decimate, 0, 1) BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(decimate_to_faces_overloads, decimate_to_faces, 0, 2) BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_max_err_overloads, set_max_err, 1, 2) @@ -108,7 +110,7 @@ void expose_decimater(const char *_name) { char buffer[64]; snprintf(buffer, sizeof buffer, "%s%s", _name, "Decimater"); - class_(buffer, init()) + class_(buffer, INIT_MESH_REF) .def("decimate", &Decimater::decimate, decimate_overloads()) .def("decimate_to", &Decimater::decimate_to) .def("decimate_to_faces", &Decimater::decimate_to_faces, decimate_to_faces_overloads()) @@ -168,7 +170,7 @@ void expose_decimater(const char *_name) { snprintf(buffer, sizeof buffer, "%s%s", _name, "ModAspectRatio"); - class_, boost::noncopyable>(buffer, init()) + class_, boost::noncopyable>(buffer, INIT_MESH_REF) .def("aspect_ratio", &ModAspectRatio::aspect_ratio) .def("set_aspect_ratio", &ModAspectRatio::set_aspect_ratio) ; @@ -181,7 +183,7 @@ void expose_decimater(const char *_name) { snprintf(buffer, sizeof buffer, "%s%s", _name, "ModEdgeLength"); - class_, boost::noncopyable>(buffer, init()) + class_, boost::noncopyable>(buffer, INIT_MESH_REF) .def("edge_length", &ModEdgeLength::edge_length) .def("set_edge_length", &ModEdgeLength::set_edge_length) ; @@ -194,7 +196,7 @@ void expose_decimater(const char *_name) { snprintf(buffer, sizeof buffer, "%s%s", _name, "ModHausdorff"); - class_, boost::noncopyable>(buffer, init()) + class_, boost::noncopyable>(buffer, INIT_MESH_REF) .def("tolerance", &ModHausdorff::tolerance) .def("set_tolerance", &ModHausdorff::set_tolerance) ; @@ -207,7 +209,7 @@ void expose_decimater(const char *_name) { snprintf(buffer, sizeof buffer, "%s%s", _name, "ModIndependentSets"); - class_, boost::noncopyable>(buffer, init()); + class_, boost::noncopyable>(buffer, INIT_MESH_REF); snprintf(buffer, sizeof buffer, "%s%s", _name, "ModIndependentSetsHandle"); expose_module_handle(buffer); @@ -217,7 +219,7 @@ void expose_decimater(const char *_name) { snprintf(buffer, sizeof buffer, "%s%s", _name, "ModNormalDeviation"); - class_, boost::noncopyable>(buffer, init()) + class_, boost::noncopyable>(buffer, INIT_MESH_REF) .def("normal_deviation", &ModNormalDeviation::normal_deviation) .def("set_normal_deviation", &ModNormalDeviation::set_normal_deviation) ; @@ -230,7 +232,7 @@ void expose_decimater(const char *_name) { snprintf(buffer, sizeof buffer, "%s%s", _name, "ModNormalFlipping"); - class_, boost::noncopyable>(buffer, init()) + class_, boost::noncopyable>(buffer, INIT_MESH_REF) .def("max_normal_deviation", &ModNormalFlipping::max_normal_deviation) .def("set_max_normal_deviation", &ModNormalFlipping::set_max_normal_deviation) ; @@ -250,7 +252,7 @@ void expose_decimater(const char *_name) { snprintf(buffer, sizeof buffer, "%s%s", _name, "ModProgMesh"); - class_, boost::noncopyable>(buffer, init()) + class_, boost::noncopyable>(buffer, INIT_MESH_REF) .def("pmi", &infolist) .def("infolist", &infolist) .def("write", &ModProgMesh::write) @@ -264,7 +266,7 @@ void expose_decimater(const char *_name) { snprintf(buffer, sizeof buffer, "%s%s", _name, "ModQuadric"); - class_, boost::noncopyable>(buffer, init()) + class_, boost::noncopyable>(buffer, INIT_MESH_REF) .def("set_max_err", &ModQuadric::set_max_err, set_max_err_overloads()) .def("unset_max_err", &ModQuadric::unset_max_err) .def("max_err", &ModQuadric::max_err) @@ -278,7 +280,7 @@ void expose_decimater(const char *_name) { snprintf(buffer, sizeof buffer, "%s%s", _name, "ModRoundness"); - class_, boost::noncopyable>(buffer, init()) + class_, boost::noncopyable>(buffer, INIT_MESH_REF) .def("set_min_angle", &ModRoundness::set_min_angle) .def("set_min_roundness", &ModRoundness::set_min_roundness, set_min_roundness_overloads()) .def("unset_min_roundness", &ModRoundness::unset_min_roundness) diff --git a/src/Python/PropertyManager.hh b/src/Python/PropertyManager.hh index 515d5cc6..3fe21f02 100644 --- a/src/Python/PropertyManager.hh +++ b/src/Python/PropertyManager.hh @@ -111,8 +111,8 @@ void expose_property_manager(const char *_name) { // Expose property manager class_(_name) - .def(init >()) - .def(init >()) + .def(init >()[with_custodian_and_ward<1,2>()]) + .def(init >()[with_custodian_and_ward<1,2>()]) .def("swap", &PropertyManager::swap) .def("is_valid", &PropertyManager::isValid)