[TD] App: remove some superfluous nullptr checks

This commit is contained in:
Uwe
2022-07-19 02:03:50 +02:00
parent 32ab100ed5
commit 36add10c86
27 changed files with 131 additions and 143 deletions

View File

@@ -556,7 +556,7 @@ private:
if (dvp->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
TechDraw::DrawProjGroupItem* dpgi = static_cast<TechDraw::DrawProjGroupItem*>(dvp);
TechDraw::DrawProjGroup* dpg = dpgi->getPGroup();
if (dpg != nullptr) {
if (dpg) {
offX = dpg->X.getValue();
offY = dpg->Y.getValue();
}

View File

@@ -427,7 +427,7 @@ std::string CosmeticEdge::toString(void) const
{
std::stringstream ss;
ss << getTagAsString() << ", $$$, ";
if (m_geometry != nullptr) {
if (m_geometry) {
ss << m_geometry->geomType <<
",$$$," <<
m_geometry->toString() <<
@@ -721,7 +721,7 @@ CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat,
return nullptr;
}
TechDraw::CenterLine* cl = new TechDraw::CenterLine(ends.first, ends.second);
if (cl != nullptr) {
if (cl) {
cl->m_type = type;
cl->m_mode = mode;
cl->m_faces = faces;
@@ -1013,7 +1013,7 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Lines(DrawVi
}
int idx = TechDraw::DrawUtil::getIndexFromName(en);
TechDraw::BaseGeomPtr bg = partFeat->getGeomByIndex(idx);
if (bg != nullptr) {
if (bg) {
edges.push_back(bg);
} else {
Base::Console().Message("CL::calcEndPoints2Lines - no geom for index: %d\n", idx);
@@ -1108,7 +1108,7 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Points(DrawV
}
int idx = TechDraw::DrawUtil::getIndexFromName(vn);
TechDraw::VertexPtr v = partFeat->getProjVertexByIndex(idx);
if (v != nullptr) {
if (v) {
points.push_back(v);
}
}

View File

@@ -134,12 +134,10 @@ void DrawDimHelper::makeExtentDim(DrawViewPart* dvp,
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
v0 = dvp->getProjVertexByIndex(idx0);
v1 = dvp->getProjVertexByIndex(idx1);
if ( (v0 != nullptr) &&
(!v0->cosmeticTag.empty()) ) {
if (v0 && !v0->cosmeticTag.empty()) {
tag0 = v0->cosmeticTag;
}
if ( (v1 != nullptr) &&
(!v1->cosmeticTag.empty()) ) {
if (v1 && !v1->cosmeticTag.empty()) {
tag1 = v1->cosmeticTag;
}
cvTags.push_back(tag0);
@@ -175,7 +173,7 @@ std::pair<Base::Vector3d, Base::Vector3d> DrawDimHelper::minMax(DrawViewPart* dv
if (!n.empty() && (geomType == "Edge")) {
int i = DrawUtil::getIndexFromName(n);
BaseGeomPtr bg = dvp->getGeomByIndex(i);
if (bg != nullptr) {
if (bg) {
bgList.push_back(bg);
}
}

View File

@@ -123,15 +123,13 @@ void DrawGeomHatch::onChanged(const App::Property* prop)
DrawGeomHatch::execute();
}
App::Document* doc = getDocument();
if ((prop == &FilePattern) &&
(doc != nullptr) ) {
if ((prop == &FilePattern) && doc) {
if (!FilePattern.isEmpty()) {
replacePatIncluded(FilePattern.getValue());
DrawGeomHatch::execute(); //remake the line sets
}
}
if ((prop == &NamePattern) &&
(doc != nullptr)) {
if ((prop == &NamePattern) && doc) {
DrawGeomHatch::execute(); //remake the line sets
}
} else {
@@ -166,7 +164,7 @@ App::DocumentObjectExecReturn *DrawGeomHatch::execute(void)
// Base::Console().Message("DGH::execute()\n");
makeLineSets();
DrawViewPart* parent = getSourceView();
if (parent != nullptr) {
if (parent) {
parent->requestPaint();
}
return App::DocumentObject::StdReturn;
@@ -608,7 +606,7 @@ void DrawGeomHatch::unsetupObject(void)
// Base::Console().Message("DGH::unsetupObject() - status: %lu removing: %d \n", getStatus(), isRemoving());
App::DocumentObject* source = Source.getValue();
DrawView* dv = dynamic_cast<DrawView*>(source);
if (dv != nullptr) {
if (dv) {
dv->requestPaint();
}
App::DocumentObject::unsetupObject();

View File

@@ -80,8 +80,7 @@ void DrawHatch::onChanged(const App::Property* prop)
DrawHatch::execute();
}
App::Document* doc = getDocument();
if ((prop == &HatchPattern) &&
(doc != nullptr) ) {
if ((prop == &HatchPattern) && doc) {
if (!HatchPattern.isEmpty()) {
replaceFileIncluded(HatchPattern.getValue());
}
@@ -267,7 +266,7 @@ void DrawHatch::unsetupObject(void)
// Base::Console().Message("DH::unsetupObject() - status: %lu removing: %d \n", getStatus(), isRemoving());
App::DocumentObject* source = Source.getValue();
DrawView* dv = dynamic_cast<DrawView*>(source);
if (dv != nullptr) {
if (dv) {
dv->requestPaint();
}
App::DocumentObject::unsetupObject();

View File

@@ -126,7 +126,7 @@ short DrawLeaderLine::mustExecute() const
}
const App::DocumentObject* docObj = getBaseObject();
if (docObj != nullptr) {
if (docObj) {
result = docObj->isTouched(); //object property points to is touched
}
if (result) {
@@ -150,9 +150,9 @@ DrawView* DrawLeaderLine::getBaseView(void) const
{
DrawView* result = nullptr;
App::DocumentObject* baseObj = LeaderParent.getValue();
if (baseObj != nullptr) {
if (baseObj) {
DrawView* cast = dynamic_cast<DrawView*>(baseObj);
if (cast != nullptr) {
if (cast) {
result = cast;
}
}
@@ -163,7 +163,7 @@ App::DocumentObject* DrawLeaderLine::getBaseObject(void) const
{
App::DocumentObject* result = nullptr;
DrawView* view = getBaseView();
if (view != nullptr) {
if (view) {
result = view;
}
return result;
@@ -173,7 +173,7 @@ bool DrawLeaderLine::keepUpdated(void)
{
bool result = false;
DrawView* view = getBaseView();
if (view != nullptr) {
if (view) {
result = view->keepUpdated();
}
return result;
@@ -186,7 +186,7 @@ double DrawLeaderLine::getBaseScale(void) const
// Base::Console().Message("DLL::getBaseScale()\n");
double result = 1.0;
DrawView* parent = getBaseView();
if (parent != nullptr) {
if (parent) {
result = parent->getScale();
} else {
//TARFU
@@ -201,7 +201,7 @@ double DrawLeaderLine::getScale(void) const
double result = 1.0;
if (Scalable.getValue()) {
DrawView* parent = getBaseView();
if (parent != nullptr) {
if (parent) {
result = parent->getScale();
} else {
//TARFU

View File

@@ -136,7 +136,7 @@ void DrawPage::onChanged(const App::Property* prop)
const std::vector<App::DocumentObject*> &vals = Views.getValues();
for(std::vector<App::DocumentObject *>::const_iterator it = vals.begin(); it < vals.end(); ++it) {
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(*it);
if (view != nullptr && view->ScaleType.isValue("Page")) {
if (view && view->ScaleType.isValue("Page")) {
if(std::abs(view->Scale.getValue() - Scale.getValue()) > FLT_EPSILON) {
view->Scale.setValue(Scale.getValue());
}
@@ -148,7 +148,7 @@ void DrawPage::onChanged(const App::Property* prop)
const std::vector<App::DocumentObject*> &vals = Views.getValues();
for(std::vector<App::DocumentObject *>::const_iterator it = vals.begin(); it < vals.end(); ++it) {
TechDraw::DrawProjGroup *view = dynamic_cast<TechDraw::DrawProjGroup *>(*it);
if (view != nullptr && view->ProjectionType.isValue("Default")) {
if (view && view->ProjectionType.isValue("Default")) {
view->ProjectionType.touch();
}
}
@@ -345,16 +345,16 @@ void DrawPage::updateAllViews()
for(; it != featViews.end(); ++it) {
TechDraw::DrawViewPart *part = dynamic_cast<TechDraw::DrawViewPart *>(*it);
TechDraw::DrawViewCollection *collect = dynamic_cast<TechDraw::DrawViewCollection*>(*it);
if (part != nullptr) {
if (part) {
part->recomputeFeature();
} else if (collect != nullptr) {
} else if (collect) {
collect->recomputeFeature();
}
}
//second, make sure all the Dimensions have been executed so Measurements have References
for(it = featViews.begin(); it != featViews.end(); ++it) {
TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension *>(*it);
if (dim != nullptr) {
if (dim) {
dim->recomputeFeature();
}
}
@@ -362,7 +362,7 @@ void DrawPage::updateAllViews()
//third, try to execute all leader lines. may not work if parent DVP isn't ready.
for(it = featViews.begin(); it != featViews.end(); ++it) {
TechDraw::DrawLeaderLine *line = dynamic_cast<TechDraw::DrawLeaderLine *>(*it);
if (line != nullptr) {
if (line) {
line->recomputeFeature();
}
}
@@ -370,7 +370,7 @@ void DrawPage::updateAllViews()
//fourth, try to execute all spreadsheets.
for (it = featViews.begin(); it != featViews.end(); ++it) {
TechDraw::DrawViewSpreadsheet *sheet = dynamic_cast<TechDraw::DrawViewSpreadsheet *>(*it);
if (sheet != nullptr) {
if (sheet) {
sheet->recomputeFeature();
}
}
@@ -385,7 +385,7 @@ std::vector<App::DocumentObject*> DrawPage::getAllViews(void)
allViews.push_back(v);
if (v->isDerivedFrom(TechDraw::DrawProjGroup::getClassTypeId())) {
TechDraw::DrawProjGroup* dpg = static_cast<TechDraw::DrawProjGroup*>(v);
if (dpg != nullptr) { //can't really happen!
if (dpg) { //can't really happen!
std::vector<App::DocumentObject*> pgViews = dpg->Views.getValues();
allViews.insert(allViews.end(),pgViews.begin(),pgViews.end());
}
@@ -426,7 +426,7 @@ void DrawPage::unsetupObject()
}
App::DocumentObject* tmp = Template.getValue();
if (tmp != nullptr) {
if (tmp) {
std::string templateName = Template.getValue()->getNameInDocument();
Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
docName.c_str(), templateName.c_str());

View File

@@ -359,7 +359,7 @@ App::DocumentObject * DrawProjGroup::getProjObj(const char *viewProjType) const
{
for( auto it : Views.getValues() ) {
auto projPtr( dynamic_cast<DrawProjGroupItem *>(it) );
if (projPtr == nullptr) {
if (!projPtr) {
//if an element in Views is not a DPGI, something really bad has happened somewhere
Base::Console().Log("PROBLEM - DPG::getProjObj - non DPGI entry in Views! %s / %s\n",
getNameInDocument(),viewProjType);
@@ -376,8 +376,7 @@ DrawProjGroupItem* DrawProjGroup::getProjItem(const char *viewProjType) const
{
App::DocumentObject* docObj = getProjObj(viewProjType);
auto result( dynamic_cast<TechDraw::DrawProjGroupItem *>(docObj) );
if ( (result == nullptr) &&
(docObj != nullptr) ) {
if (!result && docObj) {
//should never have a item in DPG that is not a DPGI.
Base::Console().Log("PROBLEM - DPG::getProjItem finds non-DPGI in Group %s / %s\n",
getNameInDocument(),viewProjType);
@@ -439,14 +438,13 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
auto docObj( getDocument()->addObject( "TechDraw::DrawProjGroupItem", //add to Document
FeatName.c_str() ) );
view = dynamic_cast<TechDraw::DrawProjGroupItem *>(docObj);
if ( (view == nullptr) &&
(docObj != nullptr) ) {
if (!view && docObj) {
//should never happen that we create a DPGI that isn't a DPGI!!
Base::Console().Log("PROBLEM - DPG::addProjection - created a non DPGI! %s / %s\n",
getNameInDocument(),viewProjType);
throw Base::TypeError("Error: new projection is not a DPGI!");
}
if (view != nullptr) { //coverity CID 151722
if (view) { //coverity CID 151722
// the label must be set before the view is added
view->Label.setValue(viewProjType);
addView(view); //from DrawViewCollection
@@ -484,16 +482,16 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
int DrawProjGroup::removeProjection(const char *viewProjType)
{
// TODO: shouldn't be able to delete "Front" unless deleting whole group
if ( checkViewProjType(viewProjType) ) {
if( !hasProjection(viewProjType) ) {
if (checkViewProjType(viewProjType)) {
if (!hasProjection(viewProjType)) {
throw Base::RuntimeError("The projection doesn't exist in the group");
}
// Iterate through the child views and find the projection type
for( auto it : Views.getValues() ) {
for (auto it : Views.getValues()) {
auto projPtr( dynamic_cast<TechDraw::DrawProjGroupItem *>(it) );
if( projPtr != nullptr) {
if ( strcmp(viewProjType, projPtr->Type.getValueAsString()) == 0 ) {
if (projPtr) {
if (strcmp(viewProjType, projPtr->Type.getValueAsString()) == 0) {
removeView(projPtr); // Remove from collection
getDocument()->removeObject( it->getNameInDocument() ); // Remove from the document
return Views.getValues().size();
@@ -518,7 +516,7 @@ int DrawProjGroup::purgeProjections()
DrawProjGroupItem* dpgi;
DocumentObject* dObj = views.back();
dpgi = dynamic_cast<DrawProjGroupItem*>(dObj);
if (dpgi != nullptr) {
if (dpgi) {
std::string itemName = dpgi->Type.getValueAsString();
removeProjection(itemName.c_str());
} else {
@@ -529,7 +527,7 @@ int DrawProjGroup::purgeProjections()
}
}
auto page = findParentPage();
if (page != nullptr) {
if (page) {
page->requestPaint();
}
@@ -793,7 +791,7 @@ int DrawProjGroup::getViewIndex(const char *viewTypeCStr) const
const char* projType;
DrawPage* dp = findParentPage();
if (ProjectionType.isValue("Default")) {
if (dp != nullptr) {
if (dp) {
projType = dp->ProjectionType.getValueAsString();
} else {
Base::Console().Warning("DPG: %s - can not find parent page. Using default Projection Type. (1)\n",
@@ -855,7 +853,7 @@ void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const
const char* projType;
if (ProjectionType.isValue("Default")) {
DrawPage* dp = findParentPage();
if (dp != nullptr) {
if (dp) {
projType = dp->ProjectionType.getValueAsString();
} else {
Base::Console().Error("DPG:arrangeViewPointers - %s - DPG is not on a page!\n",
@@ -1066,7 +1064,7 @@ App::Enumeration DrawProjGroup::usedProjectionType(void)
App::Enumeration ret(ProjectionTypeEnums, ProjectionType.getValueAsString());
if (ret.isValue("Default")) {
TechDraw::DrawPage * page = getPage();
if ( page != nullptr ) {
if (page) {
ret.setValue(page->ProjectionType.getValueAsString());
}
}
@@ -1077,7 +1075,7 @@ bool DrawProjGroup::hasAnchor(void)
{
bool result = false;
App::DocumentObject* docObj = Anchor.getValue();
if (docObj != nullptr) {
if (docObj) {
result = true;
}
return result;
@@ -1087,7 +1085,7 @@ TechDraw::DrawProjGroupItem* DrawProjGroup::getAnchor(void)
{
DrawProjGroupItem* result = nullptr;
App::DocumentObject* docObj = Anchor.getValue();
if (docObj != nullptr) {
if (docObj) {
result = static_cast<DrawProjGroupItem*>(docObj);
}
return result;
@@ -1104,7 +1102,7 @@ Base::Vector3d DrawProjGroup::getAnchorDirection(void)
{
Base::Vector3d result;
App::DocumentObject* docObj = Anchor.getValue();
if (docObj != nullptr) {
if (docObj) {
DrawProjGroupItem* item = static_cast<DrawProjGroupItem*>(docObj);
result = item->Direction.getValue();
} else {

View File

@@ -101,7 +101,7 @@ void DrawProjGroupItem::onChanged(const App::Property *prop)
if ((prop == &X) ||
(prop == &Y)) {
DrawProjGroup* parent = getPGroup();
if (parent != nullptr) {
if (parent) {
parent->touch(false);
}
}
@@ -121,7 +121,7 @@ bool DrawProjGroupItem::showLock(void) const
bool result = DrawView::showLock();
DrawProjGroup* parent = getPGroup();
bool parentLock = false;
if (parent != nullptr) {
if (parent) {
parentLock = parent->LockPosition.getValue();
}
@@ -167,7 +167,7 @@ void DrawProjGroupItem::autoPosition()
}
auto pgroup = getPGroup();
Base::Vector3d newPos;
if (pgroup != nullptr) {
if (pgroup) {
if (pgroup->AutoDistribute.getValue()) {
newPos = pgroup->getXYPosition(Type.getValueAsString());
X.setValue(newPos.x);
@@ -205,7 +205,7 @@ bool DrawProjGroupItem::isAnchor(void) const
{
bool result = false;
auto group = getPGroup();
if (group != nullptr) {
if (group) {
DrawProjGroupItem* anchor = group->getAnchor();
if (anchor == this) {
result = true;
@@ -253,11 +253,11 @@ Base::Vector3d DrawProjGroupItem::getXDirection(void) const
// Base::Console().Message("DPGI::getXDirection() - %s\n", Label.getValue());
Base::Vector3d result(1.0, 0.0, 0.0); //default X
App::Property* prop = getPropertyByName("XDirection");
if (prop != nullptr) {
if (prop) {
Base::Vector3d propVal = XDirection.getValue();
if (DrawUtil::fpCompare(propVal.Length(), 0.0)) { //have XDirection property, but not set
prop = getPropertyByName("RotationVector");
if (prop != nullptr) {
if (prop) {
result = RotationVector.getValue(); //use RotationVector if we have it
} else {
result = DrawViewPart::getXDirection(); //over complex.
@@ -268,7 +268,7 @@ Base::Vector3d DrawProjGroupItem::getXDirection(void) const
} else { //not sure this branch can actually happen
Base::Console().Message("DPGI::getXDirection - unexpected branch taken!\n");
prop = getPropertyByName("RotationVector");
if (prop != nullptr) {
if (prop) {
result = RotationVector.getValue();
} else {
@@ -285,7 +285,7 @@ Base::Vector3d DrawProjGroupItem::getLegacyX(const Base::Vector3d& pt,
// Base::Console().Message("DPGI::getLegacyX() - %s\n", Label.getValue());
Base::Vector3d result(1.0, 0.0, 0.0);
App::Property* prop = getPropertyByName("RotationVector");
if (prop != nullptr) {
if (prop) {
result = RotationVector.getValue();
if (DrawUtil::fpCompare(result.Length(), 0.0)) { //have RotationVector property, but not set
gp_Ax2 va = getViewAxis(pt,
@@ -336,7 +336,7 @@ double DrawProjGroupItem::getScale(void) const
{
double result = 1.0;
auto pgroup = getPGroup();
if (pgroup != nullptr) {
if (pgroup) {
result = pgroup->getScale();
if (!(result > 0.0)) {
Base::Console().Log("DPGI - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue());
@@ -348,7 +348,7 @@ double DrawProjGroupItem::getScale(void) const
void DrawProjGroupItem::unsetupObject()
{
if (getPGroup() != nullptr) {
if (getPGroup()) {
if (getPGroup()->hasProjection(Type.getValueAsString()) ) {
if ((getPGroup()->getAnchor() == this) &&
!getPGroup()->isUnsetting() ) {
@@ -365,7 +365,7 @@ void DrawProjGroupItem::unsetupObject()
int DrawProjGroupItem::countParentPages() const
{
DrawProjGroup* dpg = getPGroup();
if (dpg != nullptr) {
if (dpg) {
int count = dpg->countParentPages();
return count;
}
@@ -375,7 +375,7 @@ int DrawProjGroupItem::countParentPages() const
DrawPage* DrawProjGroupItem::findParentPage() const
{
DrawProjGroup* dpg = getPGroup();
if (dpg != nullptr) {
if (dpg) {
DrawPage* dp = dpg->findParentPage();
return dp;
}
@@ -385,7 +385,7 @@ DrawPage* DrawProjGroupItem::findParentPage() const
std::vector<DrawPage*> DrawProjGroupItem::findAllParentPages() const
{
DrawProjGroup* dpg = getPGroup();
if (dpg != nullptr) {
if (dpg) {
std::vector<DrawPage*> dps = dpg->findAllParentPages();
return dps;
}

View File

@@ -102,9 +102,9 @@ DrawView* DrawRichAnno::getBaseView(void) const
// Base::Console().Message("DRA::getBaseView() - %s\n", getNameInDocument());
DrawView* result = nullptr;
App::DocumentObject* baseObj = AnnoParent.getValue();
if (baseObj != nullptr) {
if (baseObj) {
DrawView* cast = dynamic_cast<DrawView*>(baseObj);
if (cast != nullptr) {
if (cast) {
result = cast;
}
}

View File

@@ -103,9 +103,9 @@ DrawView* DrawTile::getParent(void) const
// Base::Console().Message("DT::getParent() - %s\n", getNameInDocument());
DrawView* result = nullptr;
App::DocumentObject* baseObj = TileParent.getValue();
if (baseObj != nullptr) {
if (baseObj) {
DrawView* cast = dynamic_cast<DrawView*>(baseObj);
if (cast != nullptr) {
if (cast) {
result = cast;
}
}

View File

@@ -74,8 +74,7 @@ void DrawTileWeld::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
App::Document* doc = getDocument();
if ((prop == &SymbolFile) &&
(doc != nullptr) ) {
if ((prop == &SymbolFile) && doc) {
if (!SymbolFile.isEmpty()) {
Base::FileInfo fi(SymbolFile.getValue());
if (fi.isReadable()) {

View File

@@ -132,7 +132,7 @@ void DrawView::onChanged(const App::Property* prop)
auto page = findParentPage();
if (ScaleType.isValue("Page")) {
Scale.setStatus(App::Property::ReadOnly,true);
if (page != nullptr) {
if (page) {
if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) {
Scale.setValue(page->Scale.getValue());
}
@@ -481,7 +481,7 @@ void DrawView::handleChangedPropertyType(
if (strcmp(glink.getTypeId().getName(), TypeName) == 0) { //property in file is plg
glink.setContainer(this);
glink.Restore(reader);
if (glink.getValue() != nullptr) {
if (glink.getValue()) {
static_cast<App::PropertyLinkList*>(prop)->setScope(App::LinkScope::Global);
static_cast<App::PropertyLinkList*>(prop)->setValue(glink.getValue());
}
@@ -489,7 +489,7 @@ void DrawView::handleChangedPropertyType(
else if (strcmp(link.getTypeId().getName(), TypeName) == 0) { //property in file is pl
link.setContainer(this);
link.Restore(reader);
if (link.getValue() != nullptr) {
if (link.getValue()) {
static_cast<App::PropertyLinkList*>(prop)->setScope(App::LinkScope::Global);
static_cast<App::PropertyLinkList*>(prop)->setValue(link.getValue());
}

View File

@@ -209,7 +209,7 @@ short DrawViewBalloon::mustExecute() const
}
auto dvp = getViewPart();
if (dvp != nullptr) {
if (dvp) {
result = dvp->isTouched();
}
if (result) {

View File

@@ -163,7 +163,7 @@ void DrawViewDetail::onChanged(const App::Property* prop)
if (ScaleType.isValue("Page")) {
Scale.setStatus(App::Property::ReadOnly, true);
// apply the page-wide Scale
if (page != nullptr) {
if (page) {
if (std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) {
Scale.setValue(page->Scale.getValue());
Scale.purgeTouched();
@@ -228,11 +228,13 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
}
TopoDS_Shape shape;
if (dvs != nullptr) {
if (dvs) {
shape = dvs->getCutShape();
} else if (dpgi != nullptr) {
}
else if (dpgi) {
shape = dpgi->getSourceShapeFused();
} else {
}
else {
shape = dvp->getSourceShapeFused();
}
@@ -266,7 +268,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
double newScale = autoScale();
Scale.setValue(newScale);
Scale.purgeTouched();
if (geometryObject != nullptr) {
if (geometryObject) {
delete geometryObject;
geometryObject = nullptr;
detailExec(shape, dvp, dvs);
@@ -300,7 +302,7 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
Base::Vector3d shapeCenter = Base::Vector3d(gpCenter.X(),gpCenter.Y(),gpCenter.Z());
m_saveCentroid = shapeCenter; //centroid of original shape
if (dvs != nullptr) {
if (dvs) {
//section cutShape should already be on origin
} else {
myShape = TechDraw::moveShape(myShape, //centre shape on origin
@@ -547,7 +549,7 @@ void DrawViewDetail::unsetupObject()
// Base::Console().Message("DVD::unsetupObject()\n");
App::DocumentObject* baseObj = BaseView.getValue();
DrawView* base = dynamic_cast<DrawView*>(baseObj);
if (base != nullptr) {
if (base) {
base->requestPaint();
}
}

View File

@@ -134,8 +134,7 @@ App::DocumentObjectExecReturn *DrawViewDimExtent::execute(void)
if (cTags.size() > 1) {
v0 = dvp->getProjVertexByCosTag(cTags[0]);
v1 = dvp->getProjVertexByCosTag(cTags[1]);
if ( (v0 != nullptr) &&
(v1 != nullptr) ) {
if (v0 && v1) {
double length00 = (v0->pnt - refMin).Length();
double length11 = (v1->pnt - refMax).Length();
double length01 = (v0->pnt - refMax).Length();
@@ -195,8 +194,7 @@ pointPair DrawViewDimExtent::getPointsTwoVerts()
if (cTags.size() > 1) {
v0 = dvp->getProjVertexByCosTag(cTags[0]);
v1 = dvp->getProjVertexByCosTag(cTags[1]);
if ( (v0 != nullptr) &&
(v1 != nullptr) ) {
if (v0 && v1) {
result.first = v0->pnt;
result.second = v1->pnt;
}
@@ -210,7 +208,7 @@ bool DrawViewDimExtent::checkReferences2D() const
// Base::Console().Message("DVDE::checkReFerences2d() - %s\n",getNameInDocument());
bool result = false;
TechDraw::DrawViewPart* dvp = getViewPart();
if (dvp == nullptr) {
if (!dvp) {
return result;
}
@@ -218,8 +216,7 @@ bool DrawViewDimExtent::checkReferences2D() const
if (cTags.size() > 1) {
CosmeticVertex* cv0 = dvp->getCosmeticVertex(cTags[0]);
CosmeticVertex* cv1 = dvp->getCosmeticVertex(cTags[1]);
if ( (cv0 != nullptr) &&
(cv1 != nullptr) ) {
if (cv0 && cv1) {
result = true;
}
}

View File

@@ -1538,7 +1538,7 @@ bool DrawViewDimension::has2DReferences(void) const
const std::vector<std::string> &SubNames = References2D.getSubValues();
if (!objects.empty()) {
App::DocumentObject* testRef = objects.at(0);
if (testRef != nullptr) {
if (testRef) {
if (!SubNames.empty()) {
result = true; //not empty is good
for (auto& s: SubNames) { //but check individual entries

View File

@@ -73,8 +73,7 @@ void DrawViewImage::onChanged(const App::Property* prop)
{
App::Document* doc = getDocument();
if (!isRestoring()) {
if ((prop == &ImageFile) &&
(doc != nullptr) ) {
if ((prop == &ImageFile) && doc) {
if (!ImageFile.isEmpty()) {
replaceImageIncluded(ImageFile.getValue());
}

View File

@@ -698,7 +698,7 @@ std::vector<TechDraw::DrawViewBalloon*> DrawViewPart::getBalloons() const
const std::vector<TechDraw::VertexPtr> DrawViewPart::getVertexGeometry() const
{
std::vector<TechDraw::VertexPtr> result;
if (geometryObject != nullptr) {
if (geometryObject) {
result = geometryObject->getVertexGeometry();
}
return result;
@@ -707,7 +707,7 @@ const std::vector<TechDraw::VertexPtr> DrawViewPart::getVertexGeometry() const
const std::vector<TechDraw::FacePtr> DrawViewPart::getFaceGeometry() const
{
std::vector<TechDraw::FacePtr> result;
if (geometryObject != nullptr) {
if (geometryObject) {
result = geometryObject->getFaceGeometry();
}
return result;
@@ -716,7 +716,7 @@ const std::vector<TechDraw::FacePtr> DrawViewPart::getFaceGeometry() const
const BaseGeomPtrVector DrawViewPart::getEdgeGeometry() const
{
BaseGeomPtrVector result;
if (geometryObject != nullptr) {
if (geometryObject) {
result = geometryObject->getEdgeGeometry();
}
return result;
@@ -1010,7 +1010,7 @@ void DrawViewPart::unsetupObject()
// Remove Dimensions which reference this DVP
// must use page->removeObject first
TechDraw::DrawPage* page = findParentPage();
if (page != nullptr) {
if (page) {
std::vector<TechDraw::DrawViewDimension*> dims = getDimensions();
std::vector<TechDraw::DrawViewDimension*>::iterator it3 = dims.begin();
for (; it3 != dims.end(); it3++) {
@@ -1026,7 +1026,7 @@ void DrawViewPart::unsetupObject()
// Remove Balloons which reference this DVP
// must use page->removeObject first
page = findParentPage();
if (page != nullptr) {
if (page) {
std::vector<TechDraw::DrawViewBalloon*> balloons = getBalloons();
std::vector<TechDraw::DrawViewBalloon*>::iterator it3 = balloons.begin();
for (; it3 != balloons.end(); it3++) {
@@ -1075,7 +1075,7 @@ Base::Vector3d DrawViewPart::getXDirection(void) const
// Base::Console().Message("DVP::getXDirection() - %s\n", Label.getValue());
Base::Vector3d result(1.0, 0.0, 0.0); //default X
App::Property* prop = getPropertyByName("XDirection");
if (prop != nullptr) { //have an XDirection property
if (prop) { //have an XDirection property
Base::Vector3d propVal = XDirection.getValue();
if (DrawUtil::fpCompare(propVal.Length(), 0.0)) { //but it has no value
Base::Vector3d dir = Direction.getValue(); //make a sensible default

View File

@@ -200,7 +200,7 @@ PyObject* DrawViewPartPy::getCosmeticVertex(PyObject *args)
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertex(id);
if (cv != nullptr) {
if (cv) {
result = cv->getPyObject();
} else {
result = Py_None;
@@ -219,7 +219,7 @@ PyObject* DrawViewPartPy::getCosmeticVertexBySelection(PyObject *args)
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertexBySelection(selName);
if (cv != nullptr) {
if (cv) {
result = cv->getPyObject();
} else {
result = Py_None;
@@ -308,7 +308,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
Base::Vector3d pnt2 = static_cast<Base::VectorPy*>(pPnt2)->value();
std::string newTag = dvp->addCosmeticEdge(pnt1, pnt2);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
if (ce != nullptr) {
if (ce) {
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
@@ -356,7 +356,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine3D(PyObject *args)
std::string newTag = dvp->addCosmeticEdge(pnt1, pnt2);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
if (ce != nullptr) {
if (ce) {
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
@@ -395,7 +395,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
TechDraw::BaseGeomPtr bg = std::make_shared<TechDraw::Circle> (pnt1, radius);
std::string newTag = dvp->addCosmeticEdge(bg);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
if (ce != nullptr) {
if (ce) {
ce->permaRadius = radius;
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
@@ -438,7 +438,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
TechDraw::BaseGeomPtr bg = std::make_shared<TechDraw::AOC> (pnt1, radius, angle1, angle2);
std::string newTag = dvp->addCosmeticEdge(bg);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
if (ce != nullptr) {
if (ce) {
ce->permaRadius = radius;
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
@@ -470,7 +470,7 @@ PyObject* DrawViewPartPy::getCosmeticEdge(PyObject *args)
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(tag);
if (ce != nullptr) {
if (ce) {
result = ce->getPyObject();
} else {
Base::Console().Error("DVPPI::getCosmeticEdge - edge %s not found\n", tag);
@@ -490,7 +490,7 @@ PyObject* DrawViewPartPy::getCosmeticEdgeBySelection(PyObject *args)
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeBySelection(name);
if (ce != nullptr) {
if (ce) {
result = ce->getPyObject();
} else {
Base::Console().Error("DVPPI::getCosmeticEdgebySelection - edge for name %s not found\n", name);
@@ -513,7 +513,7 @@ PyObject* DrawViewPartPy::replaceCosmeticEdge(PyObject *args)
// DrawViewPart* dvp = getDrawViewPartPtr();
// TechDraw::CosmeticEdgePy* cePy = static_cast<TechDraw::CosmeticEdgePy*>(pNewCE);
// TechDraw::CosmeticEdge* ce = cePy->getCosmeticEdgePtr();
// if (ce != nullptr) {
// if (ce) {
// result = dvp->replaceCosmeticEdge(ce); //<<<
// dvp->refreshCEGeoms();
// dvp->requestPaint();
@@ -565,7 +565,7 @@ PyObject* DrawViewPartPy::makeCenterLine(PyObject *args)
cl = CenterLine::CenterLineBuilder(dvp,
subs,
mode); //vert,horiz,align
if (cl != nullptr) {
if (cl) {
tag = dvp->addCenterLine(cl);
} else {
std::string msg = "DVPPI:makeCenterLine - line creation failed";
@@ -589,7 +589,7 @@ PyObject* DrawViewPartPy::getCenterLine(PyObject *args)
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CenterLine* cl = dvp->getCenterLine(tag);
if (cl != nullptr) {
if (cl) {
result = cl->getPyObject();
} else {
Base::Console().Error("DVPPI::getCenterLine - centerLine %s not found\n", tag);
@@ -609,7 +609,7 @@ PyObject* DrawViewPartPy::getCenterLineBySelection(PyObject *args)
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CenterLine* cl = dvp->getCenterLineBySelection(tag);
if (cl != nullptr) {
if (cl) {
result = cl->getPyObject();
} else {
Base::Console().Error("DVPPI::getCenterLinebySelection - centerLine for tag %s not found\n", tag);
@@ -669,7 +669,7 @@ PyObject* DrawViewPartPy::formatGeometricEdge(PyObject *args)
color = DrawUtil::pyTupleToColor(pColor);
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::GeomFormat* gf = dvp->getGeomFormatBySelection(idx);
if (gf != nullptr) {
if (gf) {
gf->m_format.m_style = style;
gf->m_format.m_color = color;
gf->m_format.m_weight = weight;

View File

@@ -192,7 +192,7 @@ void DrawViewSection::onChanged(const App::Property* prop)
} else if (prop == &SectionOrigin) {
App::DocumentObject* base = BaseView.getValue();
TechDraw::DrawView* dv = dynamic_cast<TechDraw::DrawView*>(base);
if (dv != nullptr) {
if (dv) {
dv->requestPaint();
}
} else if (prop == &CutSurfaceDisplay) {
@@ -201,8 +201,7 @@ void DrawViewSection::onChanged(const App::Property* prop)
}
}
if ((prop == &FileHatchPattern) &&
(doc != nullptr) ) {
if ((prop == &FileHatchPattern) && doc) {
if (!FileHatchPattern.isEmpty()) {
Base::FileInfo fi(FileHatchPattern.getValue());
if (fi.isReadable()) {
@@ -211,8 +210,7 @@ void DrawViewSection::onChanged(const App::Property* prop)
}
}
if ( (prop == &FileGeomPattern) &&
(doc != nullptr) ) {
if ((prop == &FileGeomPattern) && doc) {
if (!FileGeomPattern.isEmpty()) {
Base::FileInfo fi(FileGeomPattern.getValue());
if (fi.isReadable()) {
@@ -340,7 +338,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
double newScale = autoScale();
Scale.setValue(newScale);
Scale.purgeTouched();
if (geometryObject != nullptr) {
if (geometryObject) {
delete geometryObject;
geometryObject = nullptr;
sectionExec(baseShape);
@@ -522,7 +520,7 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape)
iedge++;
const TopoDS_Edge& edge = TopoDS::Edge(expWire.Current());
TechDraw::BaseGeomPtr e = BaseGeom::baseFactory(edge);
if (e != nullptr) {
if (e) {
w->geoms.push_back(e);
}
}
@@ -646,7 +644,7 @@ Base::Vector3d DrawViewSection::getXDirection(void) const
// Base::Console().Message("DVS::getXDirection() - %s\n", Label.getValue());
Base::Vector3d result(1.0, 0.0, 0.0); //default X
App::Property* prop = getPropertyByName("XDirection");
if (prop != nullptr) { //have an XDirection property
if (prop) { //have an XDirection property
Base::Vector3d propVal = XDirection.getValue();
if (DrawUtil::fpCompare(propVal.Length(), 0.0)) { //but it has no value
std::string sectName = SectionDirection.getValueAsString();
@@ -810,7 +808,7 @@ TopoDS_Face DrawViewSection::getSectionTFace(int i)
void DrawViewSection::unsetupObject()
{
TechDraw::DrawViewPart* base = getBaseDVP();
if (base != nullptr) {
if (base) {
base->touch();
}
DrawViewPart::unsetupObject();
@@ -820,7 +818,7 @@ TechDraw::DrawViewPart* DrawViewSection::getBaseDVP() const
{
TechDraw::DrawViewPart* baseDVP = nullptr;
App::DocumentObject* base = BaseView.getValue();
if (base != nullptr) {
if (base) {
if (base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
baseDVP = static_cast<TechDraw::DrawViewPart*>(base);
}
@@ -832,7 +830,7 @@ TechDraw::DrawProjGroupItem* DrawViewSection::getBaseDPGI() const
{
TechDraw::DrawProjGroupItem* baseDPGI = nullptr;
App::DocumentObject* base = BaseView.getValue();
if (base != nullptr) {
if (base) {
if (base->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
baseDPGI = static_cast<TechDraw::DrawProjGroupItem*>(base);
}

View File

@@ -50,7 +50,7 @@ PyObject* DrawViewSymbolPy::dumpSymbol(PyObject *args)
}
auto dvs = getDrawViewSymbolPtr();
std::string symbolRepr;
if (dvs != nullptr) {
if (dvs) {
symbolRepr = dvs->Symbol.getValue();
}

View File

@@ -91,14 +91,14 @@ void DrawWeldSymbol::onSettingDocument()
std::string tileName1 = doc->getUniqueObjectName("TileWeld");
auto tile1Obj( doc->addObject( "TechDraw::DrawTileWeld", tileName1.c_str() ) );
DrawTileWeld* tile1 = dynamic_cast<DrawTileWeld*>(tile1Obj);
if (tile1 != nullptr) {
if (tile1) {
tile1->TileParent.setValue(this);
}
std::string tileName2 = doc->getUniqueObjectName("TileWeld");
auto tile2Obj( doc->addObject( "TechDraw::DrawTileWeld", tileName2.c_str() ) );
DrawTileWeld* tile2 = dynamic_cast<DrawTileWeld*>(tile2Obj);
if (tile2 != nullptr) {
if (tile2) {
tile2->TileParent.setValue(this);
tile2->TileRow.setValue(-1); //other side is row -1
}
@@ -152,7 +152,7 @@ bool DrawWeldSymbol::isTailRightSide()
bool result = true;
App::DocumentObject* obj = Leader.getValue();
TechDraw::DrawLeaderLine* realLeader = dynamic_cast<TechDraw::DrawLeaderLine*>(obj);
if (realLeader != nullptr) {
if (realLeader) {
Base::Vector3d tail = realLeader->getTailPoint();
Base::Vector3d kink = realLeader->getKinkPoint();
if (tail.x < kink.x) { //tail is to left

View File

@@ -109,7 +109,7 @@ Wire::Wire(const TopoDS_Wire &w)
for (; edges.More(); edges.Next()) {
const auto edge( TopoDS::Edge(edges.Current()) );
BaseGeomPtr bg = BaseGeom::baseFactory(edge);
if (bg != nullptr) {
if (bg) {
geoms.push_back(bg);
} else {
Base::Console().Log("G::Wire - baseFactory returned null geom ptr\n");
@@ -192,7 +192,7 @@ BaseGeomPtr BaseGeom::copy()
BaseGeomPtr result;
if (!occEdge.IsNull()) {
result = baseFactory(occEdge);
if (result != nullptr) {
if (result) {
result->extractType = extractType;
result->classOfEdge = classOfEdge;
result->hlrVisible = hlrVisible;

View File

@@ -716,9 +716,9 @@ void GeometryObject::addFaceGeom(FacePtr f)
TechDraw::DrawViewDetail* GeometryObject::isParentDetail()
{
TechDraw::DrawViewDetail* result = nullptr;
if (m_parent != nullptr) {
if (m_parent) {
TechDraw::DrawViewDetail* detail = dynamic_cast<TechDraw::DrawViewDetail*>(m_parent);
if (detail != nullptr) {
if (detail) {
result = detail;
}
}

View File

@@ -209,7 +209,7 @@ pointPair LandmarkDimension::getPointsTwoVerts()
pointPair result;
TechDraw::DrawViewPart* dvp = getViewPart();
if (dvp != nullptr) {
if (dvp) {
std::vector<Base::Vector3d> points = get2DPoints();
result.first = points.at(0) * dvp->getScale();
result.second = points.at(1) * dvp->getScale();
@@ -229,7 +229,7 @@ DrawViewPart* LandmarkDimension::getViewPart() const
std::vector<App::DocumentObject*> refs2d = References2D.getValues();
App::DocumentObject* obj = refs2d.front();
DrawViewPart* dvp = dynamic_cast<DrawViewPart*>(obj);
if (dvp != nullptr) {
if (dvp) {
result = dvp;
}
return result;

View File

@@ -70,7 +70,7 @@ std::vector<TopoDS_Shape> ShapeExtractor::getShapes2d(const std::vector<App::Doc
}
for (auto& l:links) {
const App::GroupExtension* gex = dynamic_cast<const App::GroupExtension*>(l);
if (gex != nullptr) {
if (gex) {
std::vector<App::DocumentObject*> objs = gex->Group.getValues();
for (auto& d: objs) {
if (is2dObject(d)) {
@@ -213,7 +213,7 @@ std::vector<TopoDS_Shape> ShapeExtractor::getXShapes(const App::Link* xLink)
} else {
int depth = 1; //0 is default value, related to recursion of Links???
App::DocumentObject* link = xLink->getLink(depth);
if (link != nullptr) {
if (link) {
auto shape = Part::Feature::getShape(link);
if(!shape.IsNull()) {
if (needsTransform) {
@@ -259,7 +259,7 @@ std::vector<TopoDS_Shape> ShapeExtractor::getShapesFromObject(const App::Documen
return result;
}
} else if (gex != nullptr) { //is a group extension
} else if (gex) { //is a group extension
std::vector<App::DocumentObject*> objs = gex->Group.getValues();
std::vector<TopoDS_Shape> shapes;
for (auto& d: objs) {
@@ -269,9 +269,9 @@ std::vector<TopoDS_Shape> ShapeExtractor::getShapesFromObject(const App::Documen
}
}
//the next 2 bits are mostly for Arch module objects
} else if (gProp != nullptr) { //has a Group property
} else if (gProp) { //has a Group property
App::PropertyLinkList* list = dynamic_cast<App::PropertyLinkList*>(gProp);
if (list != nullptr) {
if (list) {
std::vector<App::DocumentObject*> objs = list->getValues();
std::vector<TopoDS_Shape> shapes;
for (auto& d: objs) {
@@ -283,9 +283,9 @@ std::vector<TopoDS_Shape> ShapeExtractor::getShapesFromObject(const App::Documen
} else {
Base::Console().Log("SE::getShapesFromObject - Group is not a PropertyLinkList!\n");
}
} else if (sProp != nullptr) { //has a Shape property
} else if (sProp) { //has a Shape property
Part::PropertyPartShape* shape = dynamic_cast<Part::PropertyPartShape*>(sProp);
if (shape != nullptr) {
if (shape) {
TopoDS_Shape occShape = shape->getValue();
result.push_back(occShape);
} else {
@@ -392,7 +392,7 @@ bool ShapeExtractor::isDraftPoint(App::DocumentObject* obj)
bool result = false;
//if the docObj doesn't have a Proxy property, it definitely isn't a Draft point
App::PropertyPythonObject* proxy = dynamic_cast<App::PropertyPythonObject*>(obj->getPropertyByName("Proxy"));
if (proxy != nullptr) {
if (proxy) {
std::string pp = proxy->toString();
// Base::Console().Message("SE::isDraftPoint - pp: %s\n", pp.c_str());
if (pp.find("Point") != std::string::npos) {
@@ -414,7 +414,7 @@ Base::Vector3d ShapeExtractor::getLocation3dFromFeat(App::DocumentObject* obj)
// //if Draft option "use part primitives" is not set are Draft points still PartFeature?
Part::Feature* pf = dynamic_cast<Part::Feature*>(obj);
if (pf != nullptr) {
if (pf) {
Part::TopoShape pts = pf->Shape.getShape();
pts.setPlacement(pf->globalPlacement());
TopoDS_Shape ts = pts.getShape();