diff --git a/src/meshlabplugins/filter_mls/mlsplugin.cpp b/src/meshlabplugins/filter_mls/mlsplugin.cpp index 82d4ac99d..5cba87640 100644 --- a/src/meshlabplugins/filter_mls/mlsplugin.cpp +++ b/src/meshlabplugins/filter_mls/mlsplugin.cpp @@ -402,7 +402,7 @@ bool MlsPlugin::applyFilter(QAction* filter, MeshDocument& md, RichParameterSet& { // clone the control mesh MeshModel* ref = par.getMesh("ControlMesh"); - pPoints = new MeshModel(); + pPoints = md.addNewMesh(""); pPoints->updateDataMask(ref); vcg::tri::Append::Mesh(pPoints->cm, ref->cm); // the last true means "copy all vertices" vcg::tri::UpdateBounding::Box(pPoints->cm); @@ -604,7 +604,7 @@ bool MlsPlugin::applyFilter(QAction* filter, MeshDocument& md, RichParameterSet& delete mls; if ( (id & _PROJECTION_) && par.getMesh("ControlMesh")!=pPoints) { - delete pPoints; + md.delMesh(pPoints); } if (mesh)