FEM: [skip ci] fix possible crash in setupFilter() function

This commit is contained in:
wmayer
2022-03-27 11:32:33 +02:00
parent a07f0b6f68
commit 4d51d1d0b1

View File

@@ -1165,14 +1165,14 @@ void setupFilter(Gui::Command* cmd, std::string Name) {
// at first we must determine the pipeline of the selection object (which can be a pipeline itself)
bool selectionIsPipeline = false;
Fem::FemPostPipeline* pipeline;
Fem::FemPostPipeline* pipeline = nullptr;
if (selObject->getTypeId() == Base::Type::fromName("Fem::FemPostPipeline")) {
pipeline = static_cast<Fem::FemPostPipeline*>(selObject);
selectionIsPipeline = true;
}
else {
auto parents = selObject->getInList();
if (parents.size()) {
if (!parents.empty()) {
for (auto parentObject : parents) {
if (parentObject->getTypeId() == Base::Type::fromName("Fem::FemPostPipeline")) {
pipeline = static_cast<Fem::FemPostPipeline*>(parentObject);
@@ -1181,6 +1181,13 @@ void setupFilter(Gui::Command* cmd, std::string Name) {
}
}
if (!pipeline) {
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("setupFilter", "Error: no post processing object selected."),
qApp->translate("setupFilter", "The filter could not be set up."));
return;
}
// create the object and add it to the pipeline
cmd->openCommand(QT_TRANSLATE_NOOP("Command", "Create filter"));
cmd->doCommand(Gui::Command::Doc, "App.activeDocument().addObject('Fem::FemPost%sFilter','%s')", Name.c_str(), FeatName.c_str());