[PD] remove superfluous nullptr checks

This commit is contained in:
Uwe
2022-07-17 15:32:23 +02:00
parent ac6235c577
commit 16b25c5dab
17 changed files with 29 additions and 29 deletions

View File

@@ -299,7 +299,7 @@ void CmdPartDesignShapeBinder::activated(int iMsg)
PartDesignGui::setEdit(support.getValue());
} else {
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true);
if (pcActiveBody == nullptr)
if (!pcActiveBody)
return;
std::string FeatName = getUniqueObjectName("ShapeBinder",pcActiveBody);

View File

@@ -340,7 +340,7 @@ bool getReferencedSelection(const App::DocumentObject* thisObj, const Gui::Selec
QString getRefStr(const App::DocumentObject* obj, const std::vector<std::string>& sub)
{
if (obj == nullptr)
if (!obj)
return QString::fromLatin1("");
if (PartDesign::Feature::isDatum(obj))
@@ -354,7 +354,7 @@ QString getRefStr(const App::DocumentObject* obj, const std::vector<std::string>
std::string buildLinkSubPythonStr(const App::DocumentObject* obj, const std::vector<std::string>& subs)
{
if ( obj == nullptr)
if (!obj)
return "None";
std::string result("[");
@@ -369,7 +369,7 @@ std::string buildLinkSubPythonStr(const App::DocumentObject* obj, const std::vec
std::string buildLinkSingleSubPythonStr(const App::DocumentObject* obj,
const std::vector<std::string>& subs)
{
if (obj == nullptr)
if (!obj)
return "None";
if (PartDesign::Feature::isDatum(obj))

View File

@@ -107,13 +107,13 @@ void TaskBooleanParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
if (body.empty())
return;
App::DocumentObject* pcBody = pcBoolean->getDocument()->getObject(body.c_str());
if (pcBody == nullptr)
if (!pcBody)
return;
// if the selected object is not a body then get the body it is part of
if (!pcBody->getTypeId().isDerivedFrom(PartDesign::Body::getClassTypeId())) {
pcBody = PartDesign::Body::findBodyOf(pcBody);
if (pcBody == nullptr)
if (!pcBody)
return;
body = pcBody->getNameInDocument();
}

View File

@@ -460,7 +460,7 @@ void TaskHelixParameters::onAxisChanged(int num)
oldRefName = oldSubRefAxis.front();
App::PropertyLinkSub& lnk = *(axesInList[num]);
if (lnk.getValue() == nullptr) {
if (!lnk.getValue()) {
// enter reference selection mode
TaskSketchBasedParameters::onSelectReference(
AllowSelection::EDGE |
@@ -587,7 +587,7 @@ void TaskHelixParameters::getReferenceAxis(App::DocumentObject*& obj, std::vecto
int num = ui->axis->currentIndex();
const App::PropertyLinkSub& lnk = *(axesInList.at(num));
if (lnk.getValue() == nullptr) {
if (!lnk.getValue()) {
throw Base::RuntimeError("Still in reference selection mode; reference wasn't selected yet");
}
else {

View File

@@ -689,7 +689,7 @@ void TaskHoleParameters::changeEvent(QEvent* e)
void TaskHoleParameters::changedObject(const App::Document&, const App::Property& Prop)
{
// happens when aborting the command
if (vp == nullptr)
if (!vp)
return;
PartDesign::Hole* pcHole = static_cast<PartDesign::Hole*>(vp->getObject());

View File

@@ -318,7 +318,7 @@ void TaskLinearPatternParameters::onDirectionChanged(int /*num*/)
return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
try{
if(dirLinks.getCurrentLink().getValue() == nullptr){
if (!dirLinks.getCurrentLink().getValue()) {
// enter reference selection mode
hideObject();
showBase();

View File

@@ -230,7 +230,7 @@ void TaskMirroredParameters::onPlaneChanged(int /*num*/)
setupTransaction();
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
try{
if(planeLinks.getCurrentLink().getValue() == nullptr){
if (!planeLinks.getCurrentLink().getValue()) {
// enter reference selection mode
hideObject();
showBase();

View File

@@ -318,7 +318,7 @@ void TaskPolarPatternParameters::onAxisChanged(int /*num*/)
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
try{
if(axesLinks.getCurrentLink().getValue() == nullptr){
if (!axesLinks.getCurrentLink().getValue()) {
// enter reference selection mode
hideObject();
showBase();

View File

@@ -248,7 +248,7 @@ void TaskRevolutionParameters::onAxisChanged(int num)
oldRefName = oldSubRefAxis.front();
App::PropertyLinkSub &lnk = *(axesInList[num]);
if (lnk.getValue() == nullptr) {
if (!lnk.getValue()) {
// enter reference selection mode
TaskSketchBasedParameters::onSelectReference(AllowSelection::EDGE |
AllowSelection::PLANAR |
@@ -317,7 +317,7 @@ void TaskRevolutionParameters::getReferenceAxis(App::DocumentObject*& obj, std::
int num = ui->axis->currentIndex();
const App::PropertyLinkSub &lnk = *(axesInList[num]);
if (lnk.getValue() == nullptr) {
if (!lnk.getValue()) {
throw Base::RuntimeError("Still in reference selection mode; reference wasn't selected yet");
} else {
PartDesign::ProfileBased* pcRevolution = static_cast<PartDesign::ProfileBased*>(vp->getObject());

View File

@@ -142,7 +142,7 @@ QVariant TaskSketchBasedParameters::setUpToFace(const QString& text)
// Check whether this is the name of an App::Plane or Part::Datum feature
App::DocumentObject* obj = vp->getObject()->getDocument()->getObject(parts[0].toLatin1());
if (obj == nullptr)
if (!obj)
return QVariant();
if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {

View File

@@ -498,7 +498,7 @@ int ComboLinks::addLink(const App::PropertyLinkSub &lnk, QString itemText)
this->linksInList.push_back(new App::PropertyLinkSub());
App::PropertyLinkSub &newitem = *(linksInList[linksInList.size()-1]);
newitem.Paste(lnk);
if (newitem.getValue() && this->doc == nullptr)
if (newitem.getValue() && !this->doc)
this->doc = newitem.getValue()->getDocument();
return linksInList.size()-1;
}
@@ -511,7 +511,7 @@ int ComboLinks::addLink(App::DocumentObject *linkObj, std::string linkSubname, Q
this->linksInList.push_back(new App::PropertyLinkSub());
App::PropertyLinkSub &newitem = *(linksInList[linksInList.size()-1]);
newitem.setValue(linkObj,std::vector<std::string>(1,linkSubname));
if (newitem.getValue() && this->doc == nullptr)
if (newitem.getValue() && !this->doc)
this->doc = newitem.getValue()->getDocument();
return linksInList.size()-1;
}

View File

@@ -66,7 +66,7 @@ public:
*/
ComboLinks(QComboBox &combo);
ComboLinks() {_combo = nullptr; doc = nullptr;}
void setCombo(QComboBox &combo) {assert(_combo == nullptr); this->_combo = &combo; _combo->clear();}
void setCombo(QComboBox &combo) {assert(!_combo); this->_combo = &combo; _combo->clear();}
/**
* @brief addLink adds an item to the combo. Doesn't check for duplicates.

View File

@@ -56,27 +56,27 @@ using namespace Attacher;
namespace PartDesignGui {
bool setEdit(App::DocumentObject *obj, PartDesign::Body *body) {
if(!obj || !obj->getNameInDocument()) {
if (!obj || !obj->getNameInDocument()) {
FC_ERR("invalid object");
return false;
}
if(body == nullptr) {
if (!body) {
body = getBodyFor(obj, false);
if(!body) {
if (!body) {
FC_ERR("no body found");
return false;
}
}
auto *activeView = Gui::Application::Instance->activeView();
if(!activeView)
if (!activeView)
return false;
App::DocumentObject *parent = nullptr;
std::string subname;
auto activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY,&parent,&subname);
if(activeBody != body) {
if (activeBody != body) {
parent = obj;
subname.clear();
}else{
} else {
subname += obj->getNameInDocument();
subname += '.';
}

View File

@@ -505,7 +505,7 @@ void ViewProviderBody::dropObject(App::DocumentObject* obj)
e.ReportException();
}
}
else if (body->BaseFeature.getValue() == nullptr) {
else if (!body->BaseFeature.getValue()) {
body->BaseFeature.setValue(obj);
}

View File

@@ -86,11 +86,11 @@ void ViewProviderDressUp::highlightReferences(const bool on)
{
PartDesign::DressUp* pcDressUp = static_cast<PartDesign::DressUp*>(getObject());
Part::Feature* base = pcDressUp->getBaseObject (/*silent =*/ true);
if (base == nullptr)
if (!base)
return;
PartGui::ViewProviderPart* vp = dynamic_cast<PartGui::ViewProviderPart*>(
Gui::Application::Instance->getViewProvider(base));
if (vp == nullptr)
if (!vp)
return;
std::vector<std::string> faces = pcDressUp->Base.getSubValuesStartsWith("Face");

View File

@@ -46,7 +46,7 @@ void ViewProviderMultiTransform::setupContextMenu(QMenu* menu, QObject* receiver
std::vector<App::DocumentObject*> ViewProviderMultiTransform::claimChildren(void) const
{
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(getObject());
if (pcMultiTransform == nullptr)
if (!pcMultiTransform)
return std::vector<App::DocumentObject*>(); // TODO: Show error?
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();

View File

@@ -144,7 +144,7 @@ void ViewProviderShapeBinder::highlightReferences(bool on)
PartGui::ViewProviderPart* svp = dynamic_cast<PartGui::ViewProviderPart*>(
Gui::Application::Instance->getViewProvider(obj));
if (svp == nullptr)
if (!svp)
return;
if (on) {