Skip to content

Commit

Permalink
Warn if Anchor view deleted in Projection Group
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jan 30, 2017
1 parent 1738107 commit 0204b77
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/Mod/TechDraw/App/DrawProjGroup.cpp
Expand Up @@ -496,6 +496,11 @@ int DrawProjGroup::removeProjection(const char *viewProjType)
auto projPtr( dynamic_cast<TechDraw::DrawProjGroupItem *>(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();
Expand Down
13 changes: 13 additions & 0 deletions src/Mod/TechDraw/App/DrawProjGroupItem.cpp
Expand Up @@ -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())) {
Expand Down
6 changes: 1 addition & 5 deletions src/Mod/TechDraw/App/DrawProjGroupItem.h
Expand Up @@ -59,12 +59,8 @@ class TechDrawExport DrawProjGroupItem : public TechDraw::DrawViewPart
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();
Expand Down

0 comments on commit 0204b77

Please sign in to comment.