diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index c56e959642..d266a995bd 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1278,6 +1278,8 @@ std::vector DocumentItem::getAllParents(DocumentObjectItem* for (std::vector::iterator it = inlist.begin(); it != inlist.end(); ++it) { Gui::ViewProvider* vp = pDocument->getViewProvider(*it); + if(!vp) + continue; std::vector child = vp->claimChildren(); for (std::vector::iterator jt = child.begin(); jt != child.end(); ++jt) { if (*jt == obj) { diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index 7597f6bff3..e34c6d461d 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -43,6 +43,7 @@ #include #include +#include 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 grp = Model.getValues(); + for (auto obj : grp) + this->getDocument()->remObject(obj->getNameInDocument(), true); + } +} + } diff --git a/src/Mod/PartDesign/App/Body.h b/src/Mod/PartDesign/App/Body.h index eaa7376a44..6707f0ca56 100644 --- a/src/Mod/PartDesign/App/Body.h +++ b/src/Mod/PartDesign/App/Body.h @@ -27,6 +27,7 @@ #include #include +#include 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