PartDesign/Feature: add an optional parameter to getBaseObject() to prevent it from throwing exceptions
In most cases getBaseObject() is used with an exception handler which only detects if it failed but not the reason. This modification allows to use it without excess exception handlers. Also add the same parameter to SketchBased::getVerifiedSketch().
This commit is contained in:
committed by
Stefan Tröger
parent
bba3733086
commit
af385f1c57
@@ -1827,7 +1827,7 @@ void CmdPartDesignMirrored::activated(int iMsg)
|
||||
return;
|
||||
|
||||
if(features.front()->isDerivedFrom(PartDesign::SketchBased::getClassTypeId())) {
|
||||
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
|
||||
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch(/* silent =*/ true);
|
||||
if (sketch)
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.MirrorPlane = (App.activeDocument().%s, [\"V_Axis\"])",
|
||||
FeatName.c_str(), sketch->getNameInDocument());
|
||||
@@ -1874,7 +1874,7 @@ void CmdPartDesignLinearPattern::activated(int iMsg)
|
||||
return;
|
||||
|
||||
if(features.front()->isDerivedFrom(PartDesign::SketchBased::getClassTypeId())) {
|
||||
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
|
||||
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch(/* silent =*/ true);
|
||||
if (sketch)
|
||||
doCommand(Doc,"App.activeDocument().%s.Direction = (App.activeDocument().%s, [\"H_Axis\"])",
|
||||
FeatName.c_str(), sketch->getNameInDocument());
|
||||
@@ -1923,7 +1923,7 @@ void CmdPartDesignPolarPattern::activated(int iMsg)
|
||||
return;
|
||||
|
||||
if(features.front()->isDerivedFrom(PartDesign::SketchBased::getClassTypeId())) {
|
||||
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
|
||||
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch(/* silent =*/ true);
|
||||
if (sketch)
|
||||
doCommand(Doc,"App.activeDocument().%s.Axis = (App.activeDocument().%s, [\"N_Axis\"])",
|
||||
FeatName.c_str(), sketch->getNameInDocument());
|
||||
|
||||
@@ -59,11 +59,11 @@ bool TaskDlgFeatureParameters::accept() {
|
||||
throw Base::Exception("Bad object processed in the feature dialog.");
|
||||
}
|
||||
|
||||
App::DocumentObject* support = static_cast<PartDesign::Feature*>(feature)->BaseFeature.getValue();
|
||||
App::DocumentObject* previous = static_cast<PartDesign::Feature*>(feature)->getBaseObject(/* silent = */ true );
|
||||
|
||||
if (support) {
|
||||
if (previous) {
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",
|
||||
support->getNameInDocument());
|
||||
previous->getNameInDocument());
|
||||
}
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
@@ -91,12 +91,7 @@ bool TaskDlgFeatureParameters::reject()
|
||||
|
||||
// Find out previous feature we won't be able to do it after abort
|
||||
// (at least in the body case)
|
||||
App::DocumentObject* previous;
|
||||
try {
|
||||
previous = feature->getBaseObject(); // throws on errors
|
||||
} catch (const Base::Exception &ex) {
|
||||
previous = 0;
|
||||
}
|
||||
App::DocumentObject* previous = feature->getBaseObject(/* silent = */ true );
|
||||
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
@@ -167,14 +167,8 @@ void ViewProvider::updateData(const App::Property* prop)
|
||||
|
||||
bool ViewProvider::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
App::DocumentObject* previous;
|
||||
PartDesign::Feature* feature = static_cast<PartDesign::Feature*>(getObject());
|
||||
|
||||
try {
|
||||
previous = feature->getBaseObject();
|
||||
} catch (const Base::Exception &ex) {
|
||||
previous = 0;
|
||||
}
|
||||
App::DocumentObject* previous = feature->getBaseObject(/* silent = */ true );
|
||||
|
||||
// Make the tip or the previous feature visiable again with preference to the previous one
|
||||
// if the feature was visiable itself
|
||||
|
||||
Reference in New Issue
Block a user