delete features when deleting body
This commit is contained in:
@@ -1278,6 +1278,8 @@ std::vector<DocumentObjectItem*> DocumentItem::getAllParents(DocumentObjectItem*
|
||||
|
||||
for (std::vector<App::DocumentObject*>::iterator it = inlist.begin(); it != inlist.end(); ++it) {
|
||||
Gui::ViewProvider* vp = pDocument->getViewProvider(*it);
|
||||
if(!vp)
|
||||
continue;
|
||||
std::vector<App::DocumentObject*> child = vp->claimChildren();
|
||||
for (std::vector<App::DocumentObject*>::iterator jt = child.begin(); jt != child.end(); ++jt) {
|
||||
if (*jt == obj) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <Mod/Part/App/BodyBase.h>
|
||||
|
||||
#include <boost/signals.hpp>
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
@@ -121,8 +122,13 @@ public:
|
||||
|
||||
PyObject *getPyObject(void);
|
||||
|
||||
protected:
|
||||
virtual void onSettingDocument();
|
||||
|
||||
private:
|
||||
App::DocumentObject* rememberTip;
|
||||
boost::signals::scoped_connection connection;
|
||||
void onDelete(const App::DocumentObject& obj);
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
Reference in New Issue
Block a user