PartDesign: [skip ci] Improve revolution function

+ Fix hard crash when selecting an edge or face of the created feature before selecting option to choose a reference.
+ In ProfileBased::getAxis() convert OCCT into FreeCAD exception to simplify handling of calling instances.
+ Change return value of getReferencedSelection() from void to bool to mkae it easier for calling instance to detect if the selection failed.
  This is needed to avoid to add invalid items to the combo box of the revolution task panel
This commit is contained in:
wmayer
2020-10-14 15:20:52 +02:00
parent 247d88f4ae
commit ad48dd2538
4 changed files with 39 additions and 25 deletions

View File

@@ -195,21 +195,22 @@ bool CombineSelectionFilterGates::allow(App::Document* pDoc, App::DocumentObject
namespace PartDesignGui
{
void getReferencedSelection(const App::DocumentObject* thisObj, const Gui::SelectionChanges& msg,
bool getReferencedSelection(const App::DocumentObject* thisObj, const Gui::SelectionChanges& msg,
App::DocumentObject*& selObj, std::vector<std::string>& selSub)
{
selObj = nullptr;
if (!thisObj)
return;
return false;
if (strcmp(thisObj->getDocument()->getName(), msg.pDocName) != 0)
return;
return false;
selObj = thisObj->getDocument()->getObject(msg.pObjectName);
if (selObj == thisObj)
return;
return false;
std::string subname = msg.pSubName;
//check if the selection is an external reference and ask the user what to do
//of course only if thisObj is in a body, as otherwise the old workflow would not
//be supported
@@ -224,10 +225,11 @@ void getReferencedSelection(const App::DocumentObject* thisObj, const Gui::Selec
dia.setModal(true);
int result = dia.exec();
if (result == QDialog::DialogCode::Rejected) {
selObj = NULL;
return;
selObj = nullptr;
return false;
}
else if (!dlg.radioXRef->isChecked()) {
if (!dlg.radioXRef->isChecked()) {
App::Document* document = thisObj->getDocument();
document->openTransaction("Make copy");
auto copy = PartDesignGui::TaskFeaturePick::makeCopy(selObj, subname, dlg.radioIndependent->isChecked());
@@ -237,7 +239,6 @@ void getReferencedSelection(const App::DocumentObject* thisObj, const Gui::Selec
subname.erase(std::remove_if(subname.begin(), subname.end(), &isdigit), subname.end());
subname.append("1");
}
}
}
@@ -247,6 +248,8 @@ void getReferencedSelection(const App::DocumentObject* thisObj, const Gui::Selec
}
selSub = std::vector<std::string>(1,subname);
return true;
}
QString getRefStr(const App::DocumentObject* obj, const std::vector<std::string>& sub)