[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

@@ -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());