[TD]fix fail on missing base view (#7856)

This commit is contained in:
wandererfan
2022-11-22 16:46:13 -05:00
committed by WandererFan
parent 52398d8f58
commit cdda6f2c38
4 changed files with 46 additions and 3 deletions

View File

@@ -423,6 +423,39 @@ bool DrawProjGroup::hasProjection(const char *viewProjType) const
return false;
}
bool DrawProjGroup::canDelete(const char *viewProjType) const
{
// Base::Console().Message("DPG::canDelete(%s)\n", viewProjType);
TechDraw::DrawProjGroupItem* foundItem(nullptr);
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<TechDraw::DrawProjGroupItem *>(it) );
if (!view) {
//should never have a item in DPG that is not a DPGI.
Base::Console().Log("PROBLEM - DPG::hasProjection finds non-DPGI in Group %s / %s\n",
getNameInDocument(), viewProjType);
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
}
if (strcmp(viewProjType, view->Type.getValueAsString()) == 0 ) {
foundItem = view;
break;
}
}
if (foundItem) {
auto linkedItems = foundItem->getInList();
for (auto& item : linkedItems) {
if (item == this) {
continue;
}
if (item->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
return false;
}
}
}
return true;
}
App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
{
DrawProjGroupItem *view( nullptr );