From dfecb337e7fbe390492c41edc422e2cb9fcdfd72 Mon Sep 17 00:00:00 2001 From: Uwe Date: Mon, 18 Jul 2022 01:33:28 +0200 Subject: [PATCH] [PD] remove more superfluous nullptr checks --- src/Mod/PartDesign/App/FeatureDraft.cpp | 4 ++-- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 2 +- src/Mod/PartDesign/Gui/Command.cpp | 4 ++-- src/Mod/PartDesign/Gui/CommandBody.cpp | 2 +- .../PartDesign/Gui/TaskBooleanParameters.cpp | 22 +++++++++---------- .../Gui/TaskLinearPatternParameters.cpp | 2 +- .../PartDesign/Gui/TaskMirroredParameters.cpp | 2 +- .../Gui/TaskPolarPatternParameters.cpp | 2 +- .../PartDesign/Gui/TaskScaledParameters.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProvider.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProviderBody.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProviderDatum.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProviderHelix.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProviderLoft.cpp | 4 ++-- src/Mod/PartDesign/Gui/ViewProviderPipe.cpp | 8 +++---- .../Gui/ViewProviderSketchBased.cpp | 2 +- src/Mod/PartDesign/Gui/Workbench.cpp | 2 +- 17 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureDraft.cpp b/src/Mod/PartDesign/App/FeatureDraft.cpp index 54eb948573..79d1a34471 100644 --- a/src/Mod/PartDesign/App/FeatureDraft.cpp +++ b/src/Mod/PartDesign/App/FeatureDraft.cpp @@ -118,7 +118,7 @@ App::DocumentObjectExecReturn *Draft::execute(void) // Pull direction gp_Dir pullDirection; App::DocumentObject* refDirection = PullDirection.getValue(); - if (refDirection != nullptr) { + if (refDirection) { if (refDirection->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { PartDesign::Line* line = static_cast(refDirection); Base::Vector3d d = line->getDirection(); @@ -229,7 +229,7 @@ App::DocumentObjectExecReturn *Draft::execute(void) neutralPlane = adapt.Plane(); } else if (ref.ShapeType() == TopAbs_EDGE) { - if (refDirection != nullptr) { + if (refDirection) { // Create neutral plane through edge normal to pull direction TopoDS_Edge refEdge = TopoDS::Edge(ref); if (refEdge.IsNull()) diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 17eb6e23ac..0fe2753957 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -410,7 +410,7 @@ void ProfileBased::onChanged(const App::Property* prop) { if (prop == &Profile) { // if attached to a sketch then mark it as read-only - this->Placement.setStatus(App::Property::ReadOnly, Profile.getValue() != nullptr); + this->Placement.setStatus(App::Property::ReadOnly, Profile.getValue()); } FeatureAddSub::onChanged(prop); diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index dc9d611b72..ad71fd00aa 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -2558,7 +2558,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg) prevFeature = pcActiveBody->getPrevSolidFeature(trFeat); } Gui::Selection().clearSelection(); - if (prevFeature != nullptr) + if (prevFeature) Gui::Selection().addSelection(prevFeature->getDocument()->getName(), prevFeature->getNameInDocument()); openCommand(QT_TRANSLATE_NOOP("Command", "Convert to MultiTransform feature")); @@ -2608,7 +2608,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg) // Make sure the user isn't presented with an empty screen because no transformations are defined yet... App::DocumentObject* prevSolid = pcActiveBody->Tip.getValue(); - if (prevSolid != nullptr) { + if (prevSolid) { Part::Feature* feat = static_cast(prevSolid); FCMD_OBJ_CMD(Feat,"Shape = "<( Gui::Application::Instance->getViewProvider(pcBoolean->BaseFeature.getValue())); - if (vp != nullptr) + if (vp) vp->hide(); vp = dynamic_cast( Gui::Application::Instance->getViewProvider(bodies.front())); - if (vp != nullptr) + if (vp) vp->hide(); BooleanView->show(); } else { // Hide newly added body Gui::ViewProviderDocumentObject* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(bodies.back())); - if (vp != nullptr) + if (vp) vp->hide(); } } @@ -179,12 +179,12 @@ void TaskBooleanParameters::onSelectionChanged(const Gui::SelectionChanges& msg) // Make bodies visible again Gui::ViewProviderDocumentObject* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(pcBody)); - if (vp != nullptr) + if (vp) vp->show(); if (bodies.size() == 0) { Gui::ViewProviderDocumentObject* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(pcBoolean->BaseFeature.getValue())); - if (vp != nullptr) + if (vp) vp->show(); BooleanView->hide(); } @@ -212,7 +212,7 @@ void TaskBooleanParameters::onButtonBodyRemove(bool checked) { if (checked) { Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if (doc != nullptr) + if (doc) BooleanView->show(); selectionMode = bodyRemove; Gui::Selection().clearSelection(); @@ -273,12 +273,12 @@ void TaskBooleanParameters::onBodyDeleted(void) // Make bodies visible again Gui::ViewProviderDocumentObject* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(body)); - if (vp != nullptr) + if (vp) vp->show(); if (bodies.empty()) { Gui::ViewProviderDocumentObject* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(pcBoolean->BaseFeature.getValue())); - if (vp != nullptr) + if (vp) vp->show(); BooleanView->hide(); } @@ -303,7 +303,7 @@ void TaskBooleanParameters::exitSelectionMode() { selectionMode = none; Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if (doc != nullptr) + if (doc) doc->setShow(BooleanView->getObject()->getNameInDocument()); } @@ -378,8 +378,8 @@ bool TaskDlgBooleanParameters::reject() // Show the bodies again PartDesign::Boolean* obj = static_cast(BooleanView->getObject()); Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if (doc != nullptr) { - if (obj->BaseFeature.getValue() != nullptr) { + if (doc) { + if (obj->BaseFeature.getValue()) { doc->setShow(obj->BaseFeature.getValue()->getNameInDocument()); std::vector bodies = obj->Group.getValues(); for (std::vector::const_iterator b = bodies.begin(); b != bodies.end(); b++) diff --git a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp index 44f26771d5..4509d36576 100644 --- a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp @@ -141,7 +141,7 @@ void TaskLinearPatternParameters::setupUI() // Fill data into dialog elements for (std::vector::const_iterator i = originals.begin(); i != originals.end(); ++i) { const App::DocumentObject* obj = *i; - if (obj != nullptr) { + if (obj) { QListWidgetItem* item = new QListWidgetItem(); item->setText(QString::fromUtf8(obj->Label.getValue())); item->setData(Qt::UserRole, QString::fromLatin1(obj->getNameInDocument())); diff --git a/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp b/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp index 17bc2becb6..e163c365a9 100644 --- a/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp @@ -122,7 +122,7 @@ void TaskMirroredParameters::setupUI() // Fill data into dialog elements for (std::vector::const_iterator i = originals.begin(); i != originals.end(); ++i) { const App::DocumentObject* obj = *i; - if (obj != nullptr) { + if (obj) { QListWidgetItem* item = new QListWidgetItem(); item->setText(QString::fromUtf8(obj->Label.getValue())); item->setData(Qt::UserRole, QString::fromLatin1(obj->getNameInDocument())); diff --git a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp index e7a2afedca..8c75e55e3d 100644 --- a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp @@ -148,7 +148,7 @@ void TaskPolarPatternParameters::setupUI() // Fill data into dialog elements for (std::vector::const_iterator i = originals.begin(); i != originals.end(); ++i) { const App::DocumentObject* obj = *i; - if (obj != nullptr) { + if (obj) { QListWidgetItem* item = new QListWidgetItem(); item->setText(QString::fromUtf8(obj->Label.getValue())); item->setData(Qt::UserRole, QString::fromLatin1(obj->getNameInDocument())); diff --git a/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp b/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp index c2a15a97b9..bfe4f907f1 100644 --- a/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp @@ -113,7 +113,7 @@ void TaskScaledParameters::setupUI() // Fill data into dialog elements for (std::vector::const_iterator i = originals.begin(); i != originals.end(); ++i) { const App::DocumentObject* obj = *i; - if (obj != nullptr) { + if (obj) { QListWidgetItem* item = new QListWidgetItem(); item->setText(QString::fromUtf8(obj->Label.getValue())); item->setData(Qt::UserRole, QString::fromLatin1(obj->getNameInDocument())); diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 45e5a3630c..4f9d631a3e 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -248,7 +248,7 @@ bool ViewProvider::onDelete(const std::vector &) // find surrounding features in the tree Part::BodyBase* body = PartDesign::Body::findBodyOf(getObject()); - if (body != nullptr) { + if (body) { // Deletion from the tree of a feature is handled by Document.removeObject, which has no clue // about what a body is. Therefore, Bodies, although an "activable" container, know nothing // about what happens at Document level with the features they contain. diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index 1367837838..4efb1080a9 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -477,7 +477,7 @@ bool ViewProviderBody::canDropObject(App::DocumentObject* obj) const App::Part *actPart = PartDesignGui::getActivePart(); App::Part* partOfBaseFeature = App::Part::getPartOfObject(obj); - if (partOfBaseFeature != nullptr && partOfBaseFeature != actPart) + if (partOfBaseFeature && partOfBaseFeature != actPart) return false; return true; diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp index ff417cbd31..637802783d 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp @@ -289,7 +289,7 @@ bool ViewProviderDatum::doubleClicked(void) PartDesign::Body* activeBody = activeView->getActiveObject(PDBODYKEY); auto datumBody = PartDesignGui::getBodyFor(pcDatum, false); - if (datumBody != nullptr) { + if (datumBody) { if (datumBody != activeBody) { Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.ActiveView.setActiveObject('%s',%s)", diff --git a/src/Mod/PartDesign/Gui/ViewProviderHelix.cpp b/src/Mod/PartDesign/Gui/ViewProviderHelix.cpp index 764fcdd519..79c2fbc6ed 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderHelix.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderHelix.cpp @@ -93,7 +93,7 @@ void ViewProviderHelix::unsetEdit(int ModNum) std::vector ViewProviderHelix::claimChildren(void) const { std::vector temp; App::DocumentObject* sketch = static_cast(getObject())->Profile.getValue(); - if (sketch != nullptr && sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())) + if (sketch && sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())) temp.push_back(sketch); return temp; diff --git a/src/Mod/PartDesign/Gui/ViewProviderLoft.cpp b/src/Mod/PartDesign/Gui/ViewProviderLoft.cpp index e1cc9732fe..62db27be2d 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderLoft.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderLoft.cpp @@ -54,11 +54,11 @@ std::vector ViewProviderLoft::claimChildren(void)const PartDesign::Loft* pcLoft = static_cast(getObject()); App::DocumentObject* sketch = pcLoft->getVerifiedSketch(true); - if (sketch != nullptr) + if (sketch) temp.push_back(sketch); for(App::DocumentObject* obj : pcLoft->Sections.getValues()) { - if (obj != nullptr && obj->isDerivedFrom(Part::Part2DObject::getClassTypeId())) + if (obj && obj->isDerivedFrom(Part::Part2DObject::getClassTypeId())) temp.push_back(obj); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp index cf102a4fed..4bc009bd5d 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp @@ -54,20 +54,20 @@ std::vector ViewProviderPipe::claimChildren(void)const PartDesign::Pipe* pcPipe = static_cast(getObject()); App::DocumentObject* sketch = pcPipe->getVerifiedSketch(true); - if (sketch != nullptr) + if (sketch) temp.push_back(sketch); for(App::DocumentObject* obj : pcPipe->Sections.getValues()) { - if (obj != nullptr && obj->isDerivedFrom(Part::Part2DObject::getClassTypeId())) + if (obj && obj->isDerivedFrom(Part::Part2DObject::getClassTypeId())) temp.push_back(obj); } App::DocumentObject* spine = pcPipe->Spine.getValue(); - if (spine != nullptr && spine->isDerivedFrom(Part::Part2DObject::getClassTypeId())) + if (spine && spine->isDerivedFrom(Part::Part2DObject::getClassTypeId())) temp.push_back(spine); App::DocumentObject* auxspine = pcPipe->AuxillerySpine.getValue(); - if (auxspine != nullptr && auxspine->isDerivedFrom(Part::Part2DObject::getClassTypeId())) + if (auxspine && auxspine->isDerivedFrom(Part::Part2DObject::getClassTypeId())) temp.push_back(auxspine); return temp; diff --git a/src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp b/src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp index 341b22ae93..eacdcd2750 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp @@ -48,7 +48,7 @@ ViewProviderSketchBased::~ViewProviderSketchBased() std::vector ViewProviderSketchBased::claimChildren(void) const { std::vector temp; App::DocumentObject* sketch = static_cast(getObject())->Profile.getValue(); - if (sketch != nullptr && sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())) + if (sketch && sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())) temp.push_back(sketch); return temp; diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 5dc1392e94..e548438bf6 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -200,7 +200,7 @@ void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) con if ( docHaveBodies ) { bool addMoveFeature = true; - bool addMoveFeatureInTree = (body != nullptr); + bool addMoveFeatureInTree = body; for (auto sel: selection) { // if at least one selected feature cannot be moved to a body // disable the entry