[Spreadsheet] remove superfluous nullptr checks
This commit is contained in:
@@ -126,7 +126,7 @@ bool PropertySheet::isValidAlias(const std::string &candidate)
|
||||
boost::cmatch cm;
|
||||
|
||||
/* Check if it is used before */
|
||||
if (getValueFromAlias(candidate) != nullptr)
|
||||
if (getValueFromAlias(candidate))
|
||||
return false;
|
||||
|
||||
/* Check to make sure it doesn't clash with a predefined unit */
|
||||
@@ -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,28 +594,28 @@ 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);
|
||||
}
|
||||
|
||||
void PropertySheet::setForeground(CellAddress address, const App::Color &color)
|
||||
{
|
||||
Cell * cell = nonNullCellAt(address);
|
||||
assert(cell != nullptr);
|
||||
assert(cell);
|
||||
cell->setForeground(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);
|
||||
}
|
||||
|
||||
@@ -1133,7 +1133,7 @@ void PropertySheet::addDependencies(CellAddress key)
|
||||
|
||||
const Expression * expression = cell->getExpression();
|
||||
|
||||
if (expression == nullptr)
|
||||
if (!expression)
|
||||
return;
|
||||
|
||||
for(auto &var : expression->getIdentifiers()) {
|
||||
|
||||
@@ -368,7 +368,7 @@ Cell *Sheet::getNewCell(CellAddress address)
|
||||
{
|
||||
Cell * cell = getCell(address);
|
||||
|
||||
if (cell == nullptr)
|
||||
if (!cell)
|
||||
cell = cells.createCell(address);
|
||||
|
||||
return cell;
|
||||
@@ -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') {
|
||||
@@ -672,7 +672,7 @@ void Sheet::updateProperty(CellAddress key)
|
||||
{
|
||||
Cell * cell = getCell(key);
|
||||
|
||||
if (cell != nullptr) {
|
||||
if (cell) {
|
||||
std::unique_ptr<Expression> output;
|
||||
const Expression * input = cell->getExpression();
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ void SheetObserver::slotChangedObject(const DocumentObject &Obj, const Property
|
||||
else {
|
||||
const char * name = Obj.getPropertyName(&Prop);
|
||||
|
||||
if (name == nullptr)
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
if (isUpdating.find(name) != isUpdating.end())
|
||||
|
||||
@@ -123,7 +123,7 @@ PyObject* SheetPy::get(PyObject *args)
|
||||
|
||||
App::Property * prop = this->getSheetPtr()->getPropertyByName(address);
|
||||
|
||||
if (prop == nullptr) {
|
||||
if (!prop) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Invalid cell address or property: %s",address);
|
||||
return nullptr;
|
||||
|
||||
@@ -85,7 +85,7 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const
|
||||
int col = index.column();
|
||||
const Cell * cell = sheet->getCell(CellAddress(row, col));
|
||||
|
||||
if (cell == nullptr)
|
||||
if (!cell)
|
||||
cell = emptyCell;
|
||||
|
||||
//#define DEBUG_DEPS
|
||||
|
||||
Reference in New Issue
Block a user