delete features when deleting body

This commit is contained in:
Stefan Tröger
2015-07-13 06:24:47 +02:00
parent 1ebe3e729c
commit 81601959ab
3 changed files with 28 additions and 0 deletions

View File

@@ -43,6 +43,7 @@
#include <Mod/Part/App/DatumFeature.h>
#include <Mod/Part/App/PartFeature.h>
#include <boost/bind.hpp>
using namespace PartDesign;
@@ -419,4 +420,23 @@ PyObject *Body::getPyObject(void)
return Py::new_reference_to(PythonObject);
}
void Body::onSettingDocument() {
if(connection.connected())
connection.disconnect();
getDocument()->signalDeletedObject.connect(boost::bind(&Body::onDelete, this, _1));
App::DocumentObject::onSettingDocument();
}
void Body::onDelete(const App::DocumentObject& obj) {
if(&obj == this) {
//delete all child objects if needed
std::vector<DocumentObject*> grp = Model.getValues();
for (auto obj : grp)
this->getDocument()->remObject(obj->getNameInDocument(), true);
}
}
}