[FEM] remove superfluous nullptr checks

This commit is contained in:
Uwe
2022-07-18 01:45:19 +02:00
parent 5f8e0c46ee
commit fc548a4b34
23 changed files with 30 additions and 30 deletions

View File

@@ -80,7 +80,7 @@ void ConstraintBearing::onChanged(const App::Property* prop)
Height.setValue(height);
// Update base point
base = base + axis * height/2;
if (Location.getValue() != nullptr) {
if (Location.getValue()) {
base = getBasePoint(base, axis, Location, Dist.getValue());
}
BasePoint.setValue(base);

View File

@@ -182,7 +182,7 @@ void ConstraintFluidBoundary::onChanged(const App::Property* prop)
}
} else if (prop == &NormalDirection) {
// Set a default direction if no direction reference has been given
if (Direction.getValue() == nullptr) {
if (!Direction.getValue()) {
Base::Vector3d direction = NormalDirection.getValue();
if (Reversed.getValue())
direction = -direction;

View File

@@ -99,7 +99,7 @@ void ConstraintForce::onChanged(const App::Property* prop)
}
} else if (prop == &NormalDirection) {
// Set a default direction if no direction reference has been given
if (Direction.getValue() == nullptr) {
if (!Direction.getValue()) {
Base::Vector3d direction = NormalDirection.getValue();
if (Reversed.getValue())
direction = -direction;

View File

@@ -134,14 +134,14 @@ PyObject* FemMeshPy::setShape(PyObject *args)
PyObject* FemMeshPy::addHypothesis(PyObject *args)
{
PyObject* hyp;
PyObject* shp=nullptr;
PyObject* shp = nullptr;
// Since we have not a common base class for the Python binding of the
// hypotheses classes we cannot pass a certain Python type
if (!PyArg_ParseTuple(args, "O|O!",&hyp, &(Part::TopoShapePy::Type), &shp))
return nullptr;
TopoDS_Shape shape;
if (shp == nullptr)
if (!shp)
shape = getFemMeshPtr()->getSMesh()->GetShapeToMesh();
else
shape = static_cast<Part::TopoShapePy*>(shp)->getTopoShapePtr()->getShape();

View File

@@ -203,7 +203,7 @@ void FemPostPipeline::onChanged(const Property* prop)
//if we have no input the filters are responsible of grabbing the pipeline data themself
else {
//the first filter must always grab the data
if (filter->Input.getValue() != nullptr)
if (filter->Input.getValue())
filter->Input.setValue(nullptr);
//all the others need to be connected to the previous filter or grab the data, dependent on mode
@@ -216,7 +216,7 @@ void FemPostPipeline::onChanged(const Property* prop)
nextFilter->Input.setValue(filter);
}
else { //Parallel mode
if (nextFilter->Input.getValue() != nullptr)
if (nextFilter->Input.getValue())
nextFilter->Input.setValue(nullptr);
}

View File

@@ -81,7 +81,7 @@ TaskFemConstraint::TaskFemConstraint(ViewProviderFemConstraint *ConstraintView,Q
selectionMode = selref;
// Setup the dialog inside the Shaft Wizard dialog
if ((ConstraintView->wizardWidget != nullptr) && (ConstraintView->wizardSubLayout != nullptr)) {
if ((ConstraintView->wizardWidget) && (ConstraintView->wizardSubLayout)) {
// Hide the shaft wizard table widget to make more space
ConstraintView->wizardSubLayout->itemAt(0)->widget()->hide();
QGridLayout* buttons = ConstraintView->wizardSubLayout->findChild<QGridLayout*>();
@@ -105,7 +105,7 @@ TaskFemConstraint::TaskFemConstraint(ViewProviderFemConstraint *ConstraintView,Q
void TaskFemConstraint::keyPressEvent(QKeyEvent *ke)
{
if ((ConstraintView->wizardWidget != nullptr) && (ConstraintView->wizardSubLayout != nullptr))
if ((ConstraintView->wizardWidget) && (ConstraintView->wizardSubLayout))
// Prevent <Enter> from closing this dialog AND the shaft wizard dialog
// TODO: This should trigger an update in the shaft wizard but its difficult to access a python dialog from here...
if (ke->key() == Qt::Key_Return)
@@ -196,7 +196,7 @@ void TaskFemConstraint::onButtonWizOk()
void TaskFemConstraint::onButtonWizCancel()
{
Fem::Constraint* pcConstraint = static_cast<Fem::Constraint*>(ConstraintView->getObject());
if (pcConstraint != nullptr)
if (pcConstraint)
pcConstraint->getDocument()->removeObject(pcConstraint->getNameInDocument());
onButtonWizOk();
}

View File

@@ -195,7 +195,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemCo
Base::Console().Log("FemAnalysis object is not activated or no FemAnalysis in the active document, mesh dimension is unknown\n");
dimension = -1; // unknown dimension of mesh
}
if (pcMesh != nullptr) {
if (pcMesh) {
App::Property* prop = pcMesh->getPropertyByName("Shape"); // PropertyLink
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) {
App::PropertyLink* pcLink = static_cast<App::PropertyLink*>(prop);
@@ -226,7 +226,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemCo
pHeatTransferring = nullptr;
pTurbulenceModel = nullptr;
if (pcSolver != nullptr) {
if (pcSolver) {
//if only it is CFD solver, otherwise exit by SIGSEGV error, detect getPropertyByName() != NULL
if (pcSolver->getPropertyByName("HeatTransferring")) {
pHeatTransferring = static_cast<App::PropertyBool*>(pcSolver->getPropertyByName("HeatTransferring"));

View File

@@ -197,7 +197,7 @@ void ViewProviderFemConstraint::unsetEdit(int ModNum)
// clear the selection (convenience)
Gui::Selection().clearSelection();
if ((wizardWidget != nullptr) && (wizardSubLayout != nullptr) && (constraintDialog != nullptr)) {
if (wizardWidget && wizardSubLayout && constraintDialog) {
wizardWidget = nullptr;
wizardSubLayout = nullptr;
delete constraintDialog;
@@ -489,7 +489,7 @@ QObject* ViewProviderFemConstraint::findChildByName(const QObject* parent, const
return *o;
if (!(*o)->children().empty()) {
QObject* result = findChildByName(*o, name);
if (result != nullptr)
if (result)
return result;
}
}
@@ -523,7 +523,7 @@ void ViewProviderFemConstraint::checkForWizard()
if (wd == nullptr)
return;
QObject* wiz = findChildByName(wd, QString::fromLatin1("ShaftWizard"));
if (wiz != nullptr) {
if (wiz) {
wizardWidget = static_cast<QVBoxLayout*>(wiz);
wizardSubLayout = wiz->findChild<QVBoxLayout*>(QString::fromLatin1("ShaftWizardLayout"));
}

View File

@@ -83,7 +83,7 @@ bool ViewProviderFemConstraintBearing::setEdit(int ModNum)
Gui::Control().reject();
else
return false;
} else if (constraintDialog != nullptr) {
} else if (constraintDialog) {
// Another FemConstraint* dialog is already open inside the Shaft Wizard
// Ignore the request to open another dialog
return false;

View File

@@ -75,7 +75,7 @@ bool ViewProviderFemConstraintContact::setEdit(int ModNum)
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = nullptr; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != nullptr) {
if (constraintDialog) {
// Ignore the request to open another dialog
return false;
} else {

View File

@@ -68,7 +68,7 @@ bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum)
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = nullptr; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != nullptr) {
if (constraintDialog) {
// Ignore the request to open another dialog
return false;
} else {

View File

@@ -83,7 +83,7 @@ bool ViewProviderFemConstraintFixed::setEdit(int ModNum)
Gui::Control().reject();
else
return false;
} else if (constraintDialog != nullptr) {
} else if (constraintDialog) {
// Another FemConstraint* dialog is already open inside the Shaft Wizard
// Ignore the request to open another dialog
return false;

View File

@@ -81,7 +81,7 @@ bool ViewProviderFemConstraintFluidBoundary::setEdit(int ModNum)
Gui::Control().reject();
else
return false;
} else if (constraintDialog != nullptr) {
} else if (constraintDialog) {
// Another FemConstraint* dialog is already open inside the Shaft Wizard
// Ignore the request to open another dialog
return false;

View File

@@ -82,7 +82,7 @@ bool ViewProviderFemConstraintForce::setEdit(int ModNum)
Gui::Control().reject();
else
return false;
} else if (constraintDialog != nullptr) {
} else if (constraintDialog) {
// Another FemConstraint* dialog is already open inside the Shaft Wizard
// Ignore the request to open another dialog
return false;

View File

@@ -82,7 +82,7 @@ bool ViewProviderFemConstraintGear::setEdit(int ModNum)
Gui::Control().reject();
else
return false;
} else if (constraintDialog != nullptr) {
} else if (constraintDialog) {
// Another FemConstraint* dialog is already open inside the Shaft Wizard
// Ignore the request to open another dialog
return false;

View File

@@ -74,7 +74,7 @@ bool ViewProviderFemConstraintHeatflux::setEdit(int ModNum)
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = nullptr; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != nullptr) {
if (constraintDialog) {
// Ignore the request to open another dialog
return false;
} else {

View File

@@ -74,7 +74,7 @@ bool ViewProviderFemConstraintInitialTemperature::setEdit(int ModNum)
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = nullptr; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != nullptr) {
if (constraintDialog) {
// Ignore the request to open another dialog
return false;
} else {

View File

@@ -76,7 +76,7 @@ bool ViewProviderFemConstraintPlaneRotation::setEdit(int ModNum)
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = nullptr; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != nullptr) {
if (constraintDialog) {
// Ignore the request to open another dialog
return false;
} else {

View File

@@ -66,7 +66,7 @@ bool ViewProviderFemConstraintPressure::setEdit(int ModNum)
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = nullptr; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != nullptr) {
if (constraintDialog) {
// Ignore the request to open another dialog
return false;
} else {

View File

@@ -81,7 +81,7 @@ bool ViewProviderFemConstraintPulley::setEdit(int ModNum)
Gui::Control().reject();
else
return false;
} else if (constraintDialog != nullptr) {
} else if (constraintDialog) {
// Another FemConstraint* dialog is already open inside the Shaft Wizard
// Ignore the request to open another dialog
return false;

View File

@@ -66,7 +66,7 @@ bool ViewProviderFemConstraintSpring::setEdit(int ModNum)
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = nullptr; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != nullptr) {
if (constraintDialog) {
// Ignore the request to open another dialog
return false;
} else {

View File

@@ -75,7 +75,7 @@ bool ViewProviderFemConstraintTemperature::setEdit(int ModNum)
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = nullptr; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != nullptr) {
if (constraintDialog) {
// Ignore the request to open another dialog
return false;
} else {

View File

@@ -83,7 +83,7 @@ bool ViewProviderFemConstraintTransform::setEdit(int ModNum)
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = nullptr; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != nullptr) {
if (constraintDialog) {
// Ignore the request to open another dialog
return false;
} else {