Delete DPGI's when parent DPG deleted
Ensure Gui/QGIVxx is removed when App/DVxxxx is deleted
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
@@ -42,6 +44,7 @@ PROPERTY_SOURCE(TechDraw::DrawViewCollection, TechDraw::DrawView)
|
||||
|
||||
DrawViewCollection::DrawViewCollection()
|
||||
{
|
||||
nowDeleting = false;
|
||||
static const char *group = "Drawing view";
|
||||
ADD_PROPERTY_TYPE(Source ,(0), group, App::Prop_None,"Shape to view");
|
||||
ADD_PROPERTY_TYPE(Views ,(0), group, App::Prop_None,"Attached Views");
|
||||
@@ -165,6 +168,26 @@ void DrawViewCollection::onChanged(const App::Property* prop)
|
||||
TechDraw::DrawView::onChanged(prop);
|
||||
}
|
||||
|
||||
void DrawViewCollection::unsetupObject()
|
||||
{
|
||||
nowDeleting = true;
|
||||
|
||||
// Remove the collection's views from document
|
||||
App::Document* doc = getDocument();
|
||||
std::string docName = doc->getName();
|
||||
|
||||
const std::vector<App::DocumentObject*> currViews = Views.getValues();
|
||||
std::vector<App::DocumentObject*> emptyViews;
|
||||
std::vector<App::DocumentObject*>::const_iterator it = currViews.begin();
|
||||
for (; it != currViews.end(); it++) {
|
||||
std::string viewName = (*it)->getNameInDocument();
|
||||
Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
|
||||
docName.c_str(), viewName.c_str());
|
||||
}
|
||||
Views.setValues(emptyViews);
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewCollection::execute(void)
|
||||
{
|
||||
if (ScaleType.isValue("Page")) {
|
||||
|
||||
Reference in New Issue
Block a user