PartDesign/TaskDressUpParameters: fix a crash when editing a broken object

This commit is contained in:
Alexander Golubev
2015-07-24 02:52:38 +03:00
committed by Stefan Tröger
parent 984b0dd715
commit e16534eeb2
2 changed files with 12 additions and 3 deletions

View File

@@ -75,6 +75,7 @@ const bool TaskDressUpParameters::referenceSelected(const Gui::SelectionChanges&
PartDesign::DressUp* pcDressUp = static_cast<PartDesign::DressUp*>(DressUpView->getObject());
App::DocumentObject* base = this->getBase();
// TODO: Must we make a copy here instead of assigning to const char* ?
const char* fname = base->getNameInDocument();
if (strcmp(msg.pObjectName, fname) != 0)
@@ -168,10 +169,14 @@ void TaskDressUpParameters::showObject()
}
}
App::DocumentObject* TaskDressUpParameters::getBase(void) const
Part::Feature* TaskDressUpParameters::getBase(void) const
{
PartDesign::DressUp* pcDressUp = static_cast<PartDesign::DressUp*>(DressUpView->getObject());
return pcDressUp->Base.getValue();
// Unlikely but this may throw an exception in case we are started to edit an object which base feature
// was deleted. This exception will be likely unhandled inside the dialog and pass upper, But an error
// message inside the report view is better than a SEGFAULT.
// TODO: generally this situation should be prevented in ViewProviderDressUp
return pcDressUp->getBaseObject();
}
void TaskDressUpParameters::exitSelectionMode()