From 5e634c5995c4cc166686a316a5e774e28136a5dd Mon Sep 17 00:00:00 2001 From: Uwe Date: Mon, 18 Jul 2022 01:45:19 +0200 Subject: [PATCH] [FEM] remove superfluous nullptr checks --- src/Mod/Fem/App/FemConstraintBearing.cpp | 2 +- src/Mod/Fem/App/FemConstraintFluidBoundary.cpp | 2 +- src/Mod/Fem/App/FemConstraintForce.cpp | 2 +- src/Mod/Fem/App/FemMeshPyImp.cpp | 4 ++-- src/Mod/Fem/App/FemPostPipeline.cpp | 4 ++-- src/Mod/Fem/Gui/TaskFemConstraint.cpp | 6 +++--- src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp | 4 ++-- src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp | 6 +++--- src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp | 2 +- .../Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp | 2 +- 23 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Mod/Fem/App/FemConstraintBearing.cpp b/src/Mod/Fem/App/FemConstraintBearing.cpp index 2ca239ff1b..d789acb562 100644 --- a/src/Mod/Fem/App/FemConstraintBearing.cpp +++ b/src/Mod/Fem/App/FemConstraintBearing.cpp @@ -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); diff --git a/src/Mod/Fem/App/FemConstraintFluidBoundary.cpp b/src/Mod/Fem/App/FemConstraintFluidBoundary.cpp index dd323516bb..7f29c31af5 100644 --- a/src/Mod/Fem/App/FemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/App/FemConstraintFluidBoundary.cpp @@ -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; diff --git a/src/Mod/Fem/App/FemConstraintForce.cpp b/src/Mod/Fem/App/FemConstraintForce.cpp index 77ef50d9de..2c2fe4117a 100644 --- a/src/Mod/Fem/App/FemConstraintForce.cpp +++ b/src/Mod/Fem/App/FemConstraintForce.cpp @@ -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; diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index a3369084e7..275798e55e 100644 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -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(shp)->getTopoShapePtr()->getShape(); diff --git a/src/Mod/Fem/App/FemPostPipeline.cpp b/src/Mod/Fem/App/FemPostPipeline.cpp index 5fc5755c5e..01586a34d8 100644 --- a/src/Mod/Fem/App/FemPostPipeline.cpp +++ b/src/Mod/Fem/App/FemPostPipeline.cpp @@ -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); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.cpp b/src/Mod/Fem/Gui/TaskFemConstraint.cpp index 5382b0d5f9..ad7312f6f6 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraint.cpp @@ -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(); @@ -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 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(ConstraintView->getObject()); - if (pcConstraint != nullptr) + if (pcConstraint) pcConstraint->getDocument()->removeObject(pcConstraint->getNameInDocument()); onButtonWizOk(); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp index 080975943c..1419953fe3 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp @@ -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(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(pcSolver->getPropertyByName("HeatTransferring")); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp index 483474005f..40efb0ea34 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp @@ -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(wiz); wizardSubLayout = wiz->findChild(QString::fromLatin1("ShaftWizardLayout")); } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp index 66cbcf935d..bdb58909c0 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp @@ -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; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp index f8f531bfc5..ec9a6fed57 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp @@ -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 { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp index 2ae3628eb9..3ecbafb150 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp @@ -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 { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp index e27ed50a9a..3fb31ff394 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp @@ -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; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp index 6ded08293f..981bd01822 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp @@ -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; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp index 6d8490171e..13612d1d19 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp @@ -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; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp index 4028c382a8..7c5f16aa99 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp @@ -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; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp index 6faf2de8dc..2d92841528 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp @@ -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 { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp index 55e2b4ccd3..e70a5c6d37 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp @@ -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 { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp index 28d19726d4..018cce2810 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp @@ -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 { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp index b6ab0d21ce..b500bb784e 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp @@ -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 { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp index 88449e460f..ec465114fa 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp @@ -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; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp index dc9fe64542..dac1e81785 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp @@ -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 { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp index 1262b511ba..f23558b553 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp @@ -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 { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp index 3054cd1cd2..49bb6e448a 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp @@ -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 {