Mod: remove some unnecessary nullptr checks

This commit is contained in:
Uwe
2022-07-18 12:58:12 +02:00
parent a5eb40a9a6
commit 88a06f8f10
17 changed files with 37 additions and 37 deletions

View File

@@ -91,7 +91,7 @@ void MeshGrid::Rebuild (int iCtGridPerAxis)
void MeshGrid::InitGrid ()
{
assert(_pclMesh != nullptr);
assert(_pclMesh);
unsigned long i, j;

View File

@@ -79,14 +79,14 @@ int MeshPy::PyInit(PyObject* args, PyObject*)
}
else if (PyList_Check(pcObj)) {
PyObject* ret = addFacets(args);
bool ok = (ret!=nullptr);
bool ok = (ret != nullptr);
Py_XDECREF(ret);
if (!ok)
return -1;
}
else if (PyTuple_Check(pcObj)) {
PyObject* ret = addFacets(args);
bool ok = (ret!=nullptr);
bool ok = (ret != nullptr);
Py_XDECREF(ret);
if (!ok)
return -1;

View File

@@ -231,7 +231,7 @@ struct ShapeCache {
return;
if(strcmp(propName,"Shape")==0
|| strcmp(propName,"Group")==0
|| strstr(propName,"Touched")!=nullptr)
|| strstr(propName,"Touched"))
slotClear(obj);
}

View File

@@ -1464,7 +1464,7 @@ void PartGui::SteppedSelection::buildPixmaps()
void PartGui::SteppedSelection::selectionSlot(bool checked)
{
QPushButton *sender = qobject_cast<QPushButton*>(QObject::sender());
assert(sender != nullptr);
assert(sender);
std::vector<ButtonIconPairType>::iterator it;
for (it = buttons.begin(); it != buttons.end(); ++it)
if (it->first == sender)

View File

@@ -407,7 +407,7 @@ private:
try {
bool need_arc_plane = arc_plane==Area::ArcPlaneAuto;
std::list<TopoDS_Shape> wires = Area::sortWires(shapes,start!=nullptr,&pstart,
std::list<TopoDS_Shape> wires = Area::sortWires(shapes, start != nullptr, &pstart,
&pend, nullptr, &arc_plane, PARAM_PY_FIELDS(PARAM_FARG,AREA_PARAMS_SORT));
Py::List list;
for(auto &wire : wires) {

View File

@@ -124,7 +124,7 @@ void PointsGrid::Rebuild (int iCtGridPerAxis)
void PointsGrid::InitGrid ()
{
assert(_pclPoints != nullptr);
assert(_pclPoints);
unsigned long i, j;

View File

@@ -46,7 +46,7 @@ namespace KDL {
count++;
_check_istream(is);
} while (ch!='\n');
if (countp!=nullptr) *countp = count;
if (countp) *countp = count;
return ch;
}
@@ -66,7 +66,7 @@ namespace KDL {
break;
}
} while (true);
if (countp!=nullptr) *countp = count;
if (countp) *countp = count;
ch = is.get();
return ch;
}
@@ -97,7 +97,7 @@ int _EatSpace( std::istream& is,int* countp=nullptr) {
}
}
} while ((ch==' ')||(ch=='\n')||(ch=='\t'));
if (countp!=nullptr) *countp = count;
if (countp) *countp = count;
return ch;
}
@@ -189,7 +189,7 @@ void EatWord(std::istream& is,const char* delim,char* storage,int maxsize)
p = storage;
size=0;
int count = 0;
while ((count==0)&&(strchr(delim,ch)==nullptr)) {
while ((count==0)&&(strchr(delim,ch) == nullptr)) {
*p = (char) toupper(ch);
++p;
if (size==maxsize) {

View File

@@ -92,7 +92,7 @@ ViewProviderRobotObject::~ViewProviderRobotObject()
void ViewProviderRobotObject::setDragger()
{
assert(pcDragger==nullptr);
assert(!pcDragger);
pcDragger = new SoJackDragger();
pcDragger->addMotionCallback(sDraggerMotionCallback,this);
pcTcpRoot->addChild(pcDragger);

View File

@@ -46,7 +46,7 @@ GeometryFacade::GeometryFacade(): Geo(nullptr), OwnerGeo(false), SketchGeoExtens
GeometryFacade::GeometryFacade(const Part::Geometry * geometry, bool owner)
: Geo(geometry), OwnerGeo(owner)
{
assert(geometry != nullptr); // This should never be nullptr, as this constructor is protected
assert(geometry); // This should never be nullptr, as this constructor is protected
initExtension();
}

View File

@@ -7685,10 +7685,10 @@ std::string SketchObject::validateExpression(const App::ObjectIdentifier &path,
auto deps = expr->getDeps();
auto it = deps.find(this);
if(it!=deps.end()) {
if (it!=deps.end()) {
auto it2 = it->second.find("Constraints");
if(it2 != it->second.end()) {
for(auto &oid : it2->second) {
if (it2 != it->second.end()) {
for (auto &oid : it2->second) {
const Constraint * constraint = Constraints.getConstraint(oid);
if (!constraint->isDriving)
@@ -7710,7 +7710,7 @@ double SketchObject::calculateAngleViaPoint(int GeoId1, int GeoId2, double px, d
const Part::Geometry *p1=this->getGeometry(GeoId1);
const Part::Geometry *p2=this->getGeometry(GeoId2);
if(p1!=nullptr && p2!=nullptr) {
if (p1 && p2) {
int i1 = sk.addGeometry(this->getGeometry(GeoId1));
int i2 = sk.addGeometry(this->getGeometry(GeoId2));

View File

@@ -1430,7 +1430,7 @@ void TaskSketcherConstraints::slotConstraintsChanged(void)
for (int i = 0; i < ui->listWidgetConstraints->count(); ++i) {
ConstraintItem * it = dynamic_cast<ConstraintItem*>(ui->listWidgetConstraints->item(i));
assert(it != nullptr);
assert(it);
it->ConstraintNbr = i;
it->value = QVariant();

View File

@@ -470,7 +470,7 @@ void TaskSketcherElements::on_listWidgetElements_itemSelectionChanged(void)
bool multipleconsecutiveselection=false; // shift type of selection in listWidget
if (!inhibitSelectionUpdate) {
if(itf!=nullptr) {
if (itf) {
switch(element){
case 0:
itf->isLineSelected=!itf->isLineSelected;

View File

@@ -352,7 +352,7 @@ void ViewProviderSketch::forceUpdateData()
void ViewProviderSketch::activateHandler(DrawSketchHandler *newHandler)
{
assert(editCoinManager);
assert(sketchHandler == nullptr);
assert(!sketchHandler);
sketchHandler = std::unique_ptr<DrawSketchHandler>(newHandler);
Mode = STATUS_SKETCH_UseHandler;

View File

@@ -578,14 +578,14 @@ Cell * PropertySheet::nonNullCellAt(CellAddress address)
void PropertySheet::setContent(CellAddress address, const char *value)
{
Cell * cell = nonNullCellAt(address);
assert(cell != nullptr);
assert(cell);
cell->setContent(value);
}
void PropertySheet::setAlignment(CellAddress address, int _alignment)
{
Cell * cell = nonNullCellAt(address);
assert(cell != nullptr);
assert(cell);
if (cell->address != address) //Reject alignment change for merged cell except top-left one
return;
cell->setAlignment(_alignment);
@@ -594,7 +594,7 @@ void PropertySheet::setAlignment(CellAddress address, int _alignment)
void PropertySheet::setStyle(CellAddress address, const std::set<std::string> &_style)
{
Cell * cell = nonNullCellAt(address);
assert(cell != nullptr);
assert(cell);
cell->setStyle(_style);
}
@@ -608,14 +608,14 @@ void PropertySheet::setForeground(CellAddress address, const App::Color &color)
void PropertySheet::setBackground(CellAddress address, const App::Color &color)
{
Cell * cell = nonNullCellAt(address);
assert(cell != nullptr);
assert(cell);
cell->setBackground(color);
}
void PropertySheet::setDisplayUnit(CellAddress address, const std::string &unit)
{
Cell * cell = nonNullCellAt(address);
assert(cell != nullptr);
assert(cell);
cell->setDisplayUnit(unit);
}
@@ -627,7 +627,7 @@ void PropertySheet::setAlias(CellAddress address, const std::string &alias)
const Cell * aliasedCell = getValueFromAlias(alias);
Cell * cell = nonNullCellAt(address);
assert(cell != nullptr);
assert(cell);
if(aliasedCell == cell)
return;
@@ -671,14 +671,14 @@ void PropertySheet::setAlias(CellAddress address, const std::string &alias)
void PropertySheet::setComputedUnit(CellAddress address, const Base::Unit &unit)
{
Cell * cell = nonNullCellAt(address);
assert(cell != nullptr);
assert(cell);
cell->setComputedUnit(unit);
}
void PropertySheet::setSpans(CellAddress address, int rows, int columns)
{
Cell * cell = nonNullCellAt(address);
assert(cell != nullptr);
assert(cell);
cell->setSpans(rows, columns);
}

View File

@@ -384,7 +384,7 @@ Cell *Sheet::getNewCell(CellAddress address)
void Sheet::setCell(const char * address, const char * contents)
{
assert(address != nullptr && contents != nullptr);
assert(address && contents);
setCell(CellAddress(address), contents);
}
@@ -400,7 +400,7 @@ void Sheet::setCell(const char * address, const char * contents)
void Sheet::setCell(CellAddress address, const char * value)
{
assert(value != nullptr);
assert(value);
if (*value == '\0') {

View File

@@ -52,7 +52,7 @@ PropertiesDialog::PropertiesDialog(Sheet *_sheet, const std::vector<Range> &_ran
Cell * cell = sheet->getNewCell(*range);
assert(cell != nullptr);
assert(cell);
(void)cell->getForeground(foregroundColor);
(void)cell->getBackground(backgroundColor);

View File

@@ -308,7 +308,7 @@ QModelIndexList SheetTableView::selectedIndexesRaw() const
void SheetTableView::insertRows()
{
assert(sheet != nullptr);
assert(sheet);
QModelIndexList rows = selectionModel()->selectedRows();
std::vector<int> sortedRows;
@@ -345,7 +345,7 @@ void SheetTableView::insertRows()
void SheetTableView::insertRowsAfter()
{
assert(sheet != nullptr);
assert(sheet);
const auto rows = selectionModel()->selectedRows();
const auto & [min, max] = selectedMinMaxRows(rows);
assert(max - min == rows.size() - 1);
@@ -359,7 +359,7 @@ void SheetTableView::insertRowsAfter()
void SheetTableView::removeRows()
{
assert(sheet != nullptr);
assert(sheet);
QModelIndexList rows = selectionModel()->selectedRows();
std::vector<int> sortedRows;
@@ -380,7 +380,7 @@ void SheetTableView::removeRows()
void SheetTableView::insertColumns()
{
assert(sheet != nullptr);
assert(sheet);
QModelIndexList cols = selectionModel()->selectedColumns();
std::vector<int> sortedColumns;
@@ -418,7 +418,7 @@ void SheetTableView::insertColumns()
void SheetTableView::insertColumnsAfter()
{
assert(sheet != nullptr);
assert(sheet);
const auto columns = selectionModel()->selectedColumns();
const auto& [min, max] = selectedMinMaxColumns(columns);
assert(max - min == columns.size() - 1);
@@ -432,7 +432,7 @@ void SheetTableView::insertColumnsAfter()
void SheetTableView::removeColumns()
{
assert(sheet != nullptr);
assert(sheet);
QModelIndexList cols = selectionModel()->selectedColumns();
std::vector<int> sortedColumns;