[Sketch] remove superfluous nullptr checks
This commit is contained in:
@@ -105,13 +105,13 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
this->getConstraintPtr()->Type = Equal;
|
||||
valid = true;
|
||||
}
|
||||
else if (strstr(ConstraintType,"InternalAlignment") != nullptr) {
|
||||
else if (strstr(ConstraintType,"InternalAlignment")) {
|
||||
this->getConstraintPtr()->Type = InternalAlignment;
|
||||
|
||||
valid = true;
|
||||
if(strstr(ConstraintType,"EllipseMajorDiameter") != nullptr)
|
||||
if(strstr(ConstraintType,"EllipseMajorDiameter"))
|
||||
this->getConstraintPtr()->AlignmentType=EllipseMajorDiameter;
|
||||
else if(strstr(ConstraintType,"EllipseMinorDiameter") != nullptr)
|
||||
else if(strstr(ConstraintType,"EllipseMinorDiameter"))
|
||||
this->getConstraintPtr()->AlignmentType=EllipseMinorDiameter;
|
||||
else {
|
||||
this->getConstraintPtr()->AlignmentType=Undef;
|
||||
@@ -198,14 +198,14 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
this->getConstraintPtr()->Type = PointOnObject;
|
||||
valid = true;
|
||||
}
|
||||
else if (strstr(ConstraintType,"InternalAlignment") != nullptr) {
|
||||
else if (strstr(ConstraintType,"InternalAlignment")) {
|
||||
this->getConstraintPtr()->Type = InternalAlignment;
|
||||
|
||||
valid = true;
|
||||
|
||||
if(strstr(ConstraintType,"EllipseFocus1") != nullptr)
|
||||
if(strstr(ConstraintType,"EllipseFocus1"))
|
||||
this->getConstraintPtr()->AlignmentType=EllipseFocus1;
|
||||
else if(strstr(ConstraintType,"EllipseFocus2") != nullptr)
|
||||
else if(strstr(ConstraintType,"EllipseFocus2"))
|
||||
this->getConstraintPtr()->AlignmentType=EllipseFocus2;
|
||||
else {
|
||||
this->getConstraintPtr()->AlignmentType=Undef;
|
||||
@@ -313,12 +313,12 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos) intArg4;
|
||||
return 0;
|
||||
}
|
||||
else if (strstr(ConstraintType,"InternalAlignment") != nullptr) { // InteralAlignment with InternalElementIndex argument
|
||||
else if (strstr(ConstraintType,"InternalAlignment")) { // InteralAlignment with InternalElementIndex argument
|
||||
this->getConstraintPtr()->Type = InternalAlignment;
|
||||
|
||||
valid = true;
|
||||
|
||||
if(strstr(ConstraintType,"BSplineControlPoint") != nullptr) {
|
||||
if(strstr(ConstraintType,"BSplineControlPoint")) {
|
||||
this->getConstraintPtr()->AlignmentType=BSplineControlPoint;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -46,7 +46,7 @@ ExternalGeometryFacade::ExternalGeometryFacade(): Geo(nullptr), SketchGeoExtensi
|
||||
ExternalGeometryFacade::ExternalGeometryFacade(const Part::Geometry * geometry)
|
||||
: Geo(geometry)
|
||||
{
|
||||
if(geometry != nullptr)
|
||||
if(geometry)
|
||||
initExtensions();
|
||||
else
|
||||
THROWM(Base::ValueError, "ExternalGeometryFacade initialized with Geometry null pointer");
|
||||
@@ -54,7 +54,7 @@ ExternalGeometryFacade::ExternalGeometryFacade(const Part::Geometry * geometry)
|
||||
|
||||
std::unique_ptr<ExternalGeometryFacade> ExternalGeometryFacade::getFacade(Part::Geometry * geometry)
|
||||
{
|
||||
if(geometry != nullptr)
|
||||
if(geometry)
|
||||
return std::unique_ptr<ExternalGeometryFacade>(new ExternalGeometryFacade(geometry));
|
||||
else
|
||||
return std::unique_ptr<ExternalGeometryFacade>(nullptr);
|
||||
@@ -62,7 +62,7 @@ std::unique_ptr<ExternalGeometryFacade> ExternalGeometryFacade::getFacade(Part::
|
||||
|
||||
std::unique_ptr<const ExternalGeometryFacade> ExternalGeometryFacade::getFacade(const Part::Geometry * geometry)
|
||||
{
|
||||
if(geometry != nullptr)
|
||||
if(geometry)
|
||||
return std::unique_ptr<const ExternalGeometryFacade>(new ExternalGeometryFacade(geometry));
|
||||
else
|
||||
return std::unique_ptr<const ExternalGeometryFacade>(nullptr);
|
||||
@@ -72,7 +72,7 @@ void ExternalGeometryFacade::setGeometry(Part::Geometry *geometry)
|
||||
{
|
||||
Geo = geometry;
|
||||
|
||||
if(geometry != nullptr)
|
||||
if(geometry)
|
||||
initExtensions();
|
||||
else
|
||||
THROWM(Base::ValueError, "ExternalGeometryFacade initialized with Geometry null pointer");
|
||||
|
||||
@@ -53,13 +53,13 @@ GeometryFacade::GeometryFacade(const Part::Geometry * geometry, bool owner)
|
||||
|
||||
GeometryFacade::~GeometryFacade()
|
||||
{
|
||||
if (OwnerGeo && Geo != nullptr)
|
||||
if (OwnerGeo && Geo)
|
||||
delete Geo;
|
||||
}
|
||||
|
||||
std::unique_ptr<GeometryFacade> GeometryFacade::getFacade(Part::Geometry * geometry, bool owner)
|
||||
{
|
||||
if(geometry != nullptr)
|
||||
if(geometry)
|
||||
return std::unique_ptr<GeometryFacade>(new GeometryFacade(geometry, owner));
|
||||
else
|
||||
return std::unique_ptr<GeometryFacade>(nullptr);
|
||||
@@ -68,7 +68,7 @@ std::unique_ptr<GeometryFacade> GeometryFacade::getFacade(Part::Geometry * geome
|
||||
|
||||
std::unique_ptr<const GeometryFacade> GeometryFacade::getFacade(const Part::Geometry * geometry)
|
||||
{
|
||||
if(geometry != nullptr)
|
||||
if(geometry)
|
||||
return std::unique_ptr<const GeometryFacade>(new GeometryFacade(geometry));
|
||||
else
|
||||
return std::unique_ptr<const GeometryFacade>(nullptr);
|
||||
@@ -79,7 +79,7 @@ void GeometryFacade::setGeometry(Part::Geometry *geometry)
|
||||
{
|
||||
Geo = geometry;
|
||||
|
||||
if(geometry != nullptr)
|
||||
if(geometry)
|
||||
initExtension();
|
||||
else
|
||||
THROWM(Base::ValueError, "GeometryFacade initialized with Geometry null pointer");
|
||||
@@ -113,7 +113,7 @@ void GeometryFacade::initExtension() const
|
||||
|
||||
void GeometryFacade::throwOnNullPtr(const Part::Geometry * geo)
|
||||
{
|
||||
if(geo == nullptr)
|
||||
if(!geo)
|
||||
THROWM(Base::ValueError, "Geometry is nullptr!");
|
||||
}
|
||||
|
||||
|
||||
@@ -271,13 +271,13 @@ class SketcherExport GeometryTypedFacade : public GeometryFacade
|
||||
|
||||
public: // Factory methods
|
||||
static std::unique_ptr<GeometryTypedFacade<GeometryT>> getTypedFacade(GeometryT * geometry, bool owner = false) {
|
||||
if(geometry != nullptr)
|
||||
if(geometry)
|
||||
return std::unique_ptr<GeometryTypedFacade<GeometryT>>(new GeometryTypedFacade(geometry, owner));
|
||||
else
|
||||
return std::unique_ptr<GeometryTypedFacade<GeometryT>>(nullptr);
|
||||
}
|
||||
static std::unique_ptr<const GeometryTypedFacade<GeometryT>> getTypedFacade(const GeometryT * geometry) {
|
||||
if(geometry != nullptr)
|
||||
if(geometry)
|
||||
return std::unique_ptr<const GeometryTypedFacade<GeometryT>>(new GeometryTypedFacade(geometry));
|
||||
else
|
||||
return std::unique_ptr<const GeometryTypedFacade<GeometryT>>(nullptr);
|
||||
|
||||
@@ -416,7 +416,7 @@ bool Sketch::analyseBlockedConstraintDependentParameters(std::vector<int> &block
|
||||
continue;
|
||||
}
|
||||
// 4.2. satisfiable and not satisfied
|
||||
if(prop_groups[i].blocking_param_in_group == nullptr) {
|
||||
if(!prop_groups[i].blocking_param_in_group) {
|
||||
unsatisfied_groups = true;
|
||||
}
|
||||
}
|
||||
@@ -2677,7 +2677,7 @@ int Sketch::addAngleConstraint(int geoId1, PointPos pos1, int geoId2, PointPos p
|
||||
l2p2 = &Points[Geoms[geoId2].startPointId];
|
||||
}
|
||||
|
||||
if (l1p1 == nullptr || l2p1 == nullptr)
|
||||
if (!l1p1 || !l2p1)
|
||||
return -1;
|
||||
|
||||
int tag = ++ConstraintsCounter;
|
||||
|
||||
@@ -295,7 +295,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, bool
|
||||
std::set<VertexIds, VertexID_Less> *tempGrp = nullptr;
|
||||
for (auto it = coincVertexGrps.begin(); it < coincVertexGrps.end(); ++it) {
|
||||
if ( (it->find(v1) != it->end()) || (it->find(v2) != it->end()) ) {
|
||||
if (tempGrp == nullptr) {
|
||||
if (!tempGrp) {
|
||||
tempGrp = &*it;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -3343,7 +3343,7 @@ bool SketchObject::isExternalAllowed(App::Document *pDoc, App::DocumentObject *p
|
||||
App::Part* part_this = App::Part::getPartOfObject(this);
|
||||
App::Part* part_obj = App::Part::getPartOfObject(pObj);
|
||||
if (part_this == part_obj){ //either in the same part, or in the root of document
|
||||
if (body_this == nullptr) {
|
||||
if (!body_this) {
|
||||
return true;
|
||||
} else if (body_this == body_obj) {
|
||||
return true;
|
||||
@@ -3402,7 +3402,7 @@ bool SketchObject::isCarbonCopyAllowed(App::Document *pDoc, App::DocumentObject
|
||||
App::Part* part_this = App::Part::getPartOfObject(this);
|
||||
App::Part* part_obj = App::Part::getPartOfObject(pObj);
|
||||
if (part_this == part_obj){ //either in the same part, or in the root of document
|
||||
if (body_this != nullptr) {
|
||||
if (body_this) {
|
||||
if (body_this != body_obj) {
|
||||
if (!this->allowOtherBody) {
|
||||
if (rsn)
|
||||
|
||||
@@ -87,11 +87,11 @@ namespace SketcherGui {
|
||||
std::vector<Attacher::eMapMode>* allmodes = nullptr){
|
||||
//convert pointers into valid references, to avoid checking for null pointers everywhere
|
||||
Attacher::SuggestResult::eSuggestResult buf;
|
||||
if (pMsgId == nullptr)
|
||||
if (!pMsgId)
|
||||
pMsgId = &buf;
|
||||
Attacher::SuggestResult::eSuggestResult &msg = *pMsgId;
|
||||
QString buf2;
|
||||
if (message == nullptr)
|
||||
if (!message)
|
||||
message = &buf2;
|
||||
QString &msg_str = *message;
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
{
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
App::DocumentObject* obj = sketchgui->getObject()->getDocument()->getObject(msg.pObjectName);
|
||||
if (obj == nullptr)
|
||||
if (!obj)
|
||||
throw Base::ValueError("Sketcher: Carbon Copy: Invalid object in selection");
|
||||
|
||||
if (obj->getTypeId() == Sketcher::SketchObject::getClassTypeId()) {
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
{
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
App::DocumentObject* obj = sketchgui->getObject()->getDocument()->getObject(msg.pObjectName);
|
||||
if (obj == nullptr)
|
||||
if (!obj)
|
||||
throw Base::ValueError("Sketcher: External geometry: Invalid object in selection");
|
||||
std::string subName(msg.pSubName);
|
||||
if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) ||
|
||||
|
||||
@@ -85,7 +85,7 @@ void EditDatumDialog::exec(bool atCursor)
|
||||
Base::Quantity init_val;
|
||||
|
||||
QDialog dlg(Gui::getMainWindow());
|
||||
if (ui_ins_datum == nullptr) {
|
||||
if (!ui_ins_datum) {
|
||||
ui_ins_datum.reset(new Ui_InsertDatum);
|
||||
ui_ins_datum->setupUi(&dlg);
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
|
||||
}
|
||||
|
||||
const unsigned char * dataptr = this->image.getValue(imgsize, nc);
|
||||
if (dataptr == nullptr) // no image
|
||||
if (!dataptr) // no image
|
||||
return;
|
||||
|
||||
srcw = imgsize[0];
|
||||
|
||||
Reference in New Issue
Block a user