From 0204b77766b1166e0bda8542a57be625760844c1 Mon Sep 17 00:00:00 2001 From: WandererFan Date: Fri, 6 Jan 2017 09:36:03 -0500 Subject: [PATCH] Warn if Anchor view deleted in Projection Group --- src/Mod/TechDraw/App/DrawProjGroup.cpp | 5 +++++ src/Mod/TechDraw/App/DrawProjGroupItem.cpp | 13 +++++++++++++ src/Mod/TechDraw/App/DrawProjGroupItem.h | 6 +----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index a3da8149f..926a449b8 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -496,6 +496,11 @@ int DrawProjGroup::removeProjection(const char *viewProjType) auto projPtr( dynamic_cast(it) ); if( projPtr ) { if ( strcmp(viewProjType, projPtr->Type.getValueAsString()) == 0 ) { + if( strcmp(viewProjType,"Front") == 0 ) { + Base::Console().Warning("DPG - %s: Front projection deleted. Projection group may be corrupt\n", + getNameInDocument()); + Anchor.setValue(nullptr); + } removeView(projPtr); // Remove from collection getDocument()->remObject( it->getNameInDocument() ); // Remove from the document moveToCentre(); diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index 1e9cf5e5c..f772c09f1 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -160,6 +160,19 @@ double DrawProjGroupItem::getRotateAngle() return angle; } +void DrawProjGroupItem::unsetupObject() +{ + if (getGroup() != nullptr) { + if (getGroup()->hasProjection(Type.getValueAsString()) ) { + if (getGroup()->getAnchor() == this) { + Base::Console().Warning("Warning - DPG (%s/%s) may be corrupt - Anchor deleted\n", + getGroup()->getNameInDocument(),getGroup()->Label.getValue()); + getGroup()->Anchor.setValue(nullptr); + } + } + } +} + PyObject *DrawProjGroupItem::getPyObject(void) { if (PythonObject.is(Py::_None())) { diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.h b/src/Mod/TechDraw/App/DrawProjGroupItem.h index ac831f82a..8916594dd 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.h +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.h @@ -59,12 +59,8 @@ public: App::PropertyVector RotationVector; short mustExecute() const; - /** @name methods overide Feature */ - //@{ - /// recalculate the Feature virtual void onDocumentRestored(); -// virtual App::DocumentObjectExecReturn *execute(void); // TODO: Delete me too if we take out the implementation - //@} + virtual void unsetupObject(); DrawProjGroup* getGroup(void) const; double getRotateAngle();