Skip to content

Commit

Permalink
more nullptr updates (folloup 320c696)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Dec 16, 2015
1 parent c2d919a commit 8214608
Show file tree
Hide file tree
Showing 198 changed files with 603 additions and 730 deletions.
4 changes: 2 additions & 2 deletions src/analysis/interpolation/Node.cc
Expand Up @@ -39,15 +39,15 @@ Node& Node::operator=( const Node & n )
if ( n.getPoint() )//mPoint of n is not a null pointer
{
mPoint = new Point3D( n.getPoint()->getX(), n.getPoint()->getY(), n.getPoint()->getZ() );
if ( mPoint == nullptr )//no memory
if ( !mPoint )//no memory
{
mPoint = tmp;
mNext = n.getNext();
return ( *this );
}

}
else//mPoint of n is a null pointer
else//mPoint of n is a nullptr
{
mPoint = nullptr;
}
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/network/qgsgraphanalyzer.cpp
Expand Up @@ -29,7 +29,7 @@
void QgsGraphAnalyzer::dijkstra( const QgsGraph* source, int startPointIdx, int criterionNum, QVector<int>* resultTree, QVector<double>* resultCost )
{
QVector< double > * result = nullptr;
if ( resultCost != nullptr )
if ( resultCost )
{
result = resultCost;
}
Expand All @@ -42,7 +42,7 @@ void QgsGraphAnalyzer::dijkstra( const QgsGraph* source, int startPointIdx, int
result->insert( result->begin(), source->vertexCount(), std::numeric_limits<double>::infinity() );
( *result )[ startPointIdx ] = 0.0;

if ( resultTree != nullptr )
if ( resultTree )
{
resultTree->clear();
resultTree->insert( resultTree->begin(), source->vertexCount(), -1 );
Expand Down Expand Up @@ -73,15 +73,15 @@ void QgsGraphAnalyzer::dijkstra( const QgsGraph* source, int startPointIdx, int
if ( cost < ( *result )[ arc.inVertex()] )
{
( *result )[ arc.inVertex()] = cost;
if ( resultTree != nullptr )
if ( resultTree )
{
( *resultTree )[ arc.inVertex()] = *arcIt;
}
not_begin.insert( cost, arc.inVertex() );
}
}
}
if ( resultCost == nullptr )
if ( !resultCost )
{
delete result;
}
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/network/qgsgraphbuilder.cpp
Expand Up @@ -29,8 +29,7 @@ QgsGraphBuilder::QgsGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool

QgsGraphBuilder::~QgsGraphBuilder()
{
if ( mGraph != nullptr )
delete mGraph;
delete mGraph;
}

void QgsGraphBuilder::addVertex( int, const QgsPoint& pt )
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/network/qgslinevectorlayerdirector.cpp
Expand Up @@ -130,7 +130,7 @@ void QgsLineVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, c
{
QgsVectorLayer *vl = mVectorLayer;

if ( vl == nullptr )
if ( !vl )
return;

int featureCount = ( int ) vl->featureCount() * 2;
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/openstreetmap/qgsosmdatabase.cpp
Expand Up @@ -39,7 +39,7 @@ QgsOSMDatabase::~QgsOSMDatabase()

bool QgsOSMDatabase::isOpen() const
{
return mDatabase != nullptr;
return nullptr != mDatabase;
}


Expand Down Expand Up @@ -83,7 +83,7 @@ bool QgsOSMDatabase::close()
deleteStatement( mStmtWayNodePoints );
deleteStatement( mStmtWayTags );

Q_ASSERT( mStmtNode == nullptr );
Q_ASSERT( !mStmtNode );

// close database
if ( QgsSLConnect::sqlite3_close( mDatabase ) != SQLITE_OK )
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/openstreetmap/qgsosmimport.cpp
Expand Up @@ -232,7 +232,7 @@ bool QgsOSMXmlImport::closeDatabase()
deleteStatement( mStmtInsertWayNode );
deleteStatement( mStmtInsertWayTag );

Q_ASSERT( mStmtInsertNode == nullptr );
Q_ASSERT( !mStmtInsertNode );

QgsSLConnect::sqlite3_close( mDatabase );
mDatabase = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/raster/qgsalignraster.cpp
Expand Up @@ -458,7 +458,7 @@ bool QgsAlignRaster::createAndWarp( const Item& raster )

// Copy the color table, if required.
GDALColorTableH hCT = GDALGetRasterColorTable( GDALGetRasterBand( hSrcDS, 1 ) );
if ( hCT != nullptr )
if ( hCT )
GDALSetRasterColorTable( GDALGetRasterBand( hDstDS, 1 ), hCT );

// -----------------------------------------------------------------------
Expand Down Expand Up @@ -521,7 +521,7 @@ bool QgsAlignRaster::suggestedWarpOutput( const QgsAlignRaster::RasterInfo& info
// Create a transformer that maps from source pixel/line coordinates
// to destination georeferenced coordinates (not destination
// pixel line). We do that by omitting the destination dataset
// handle (setting it to NULL).
// handle (setting it to nullptr).
void* hTransformArg = GDALCreateGenImgProjTransformer( info.mDataset, info.mCrsWkt.toAscii().constData(), nullptr, destWkt.toAscii().constData(), FALSE, 0, 1 );
if ( !hTransformArg )
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/raster/qgsalignraster.h
Expand Up @@ -49,7 +49,7 @@ class ANALYSIS_EXPORT QgsAlignRaster
~RasterInfo();

//! Check whether the given path is a valid raster
bool isValid() const { return mDataset != nullptr; }
bool isValid() const { return nullptr != mDataset; }

//! Return CRS in WKT format
QString crs() const { return mCrsWkt; }
Expand Down Expand Up @@ -138,9 +138,9 @@ class ANALYSIS_EXPORT QgsAlignRaster
virtual ~ProgressHandler() {}
};

//! Assign a progress handler instance. Does not take ownership. NULL can be passed.
//! Assign a progress handler instance. Does not take ownership. nullptr can be passed.
void setProgressHandler( ProgressHandler* progressHandler ) { mProgressHandler = progressHandler; }
//! Get associated progress handler. May be NULL (default)
//! Get associated progress handler. May be nullptr (default)
ProgressHandler* progressHandler() const { return mProgressHandler; }

//! Set list of rasters that will be aligned
Expand Down
20 changes: 10 additions & 10 deletions src/analysis/raster/qgsninecellfilter.cpp
Expand Up @@ -60,27 +60,27 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p )
//open input file
int xSize, ySize;
GDALDatasetH inputDataset = openInputFile( xSize, ySize );
if ( inputDataset == nullptr )
if ( !inputDataset )
{
return 1; //opening of input file failed
}

//output driver
GDALDriverH outputDriver = openOutputDriver();
if ( outputDriver == nullptr )
if ( !outputDriver )
{
return 2;
}

GDALDatasetH outputDataset = openOutputFile( inputDataset, outputDriver );
if ( outputDataset == nullptr )
if ( !outputDataset )
{
return 3; //create operation on output file failed
}

//open first raster band for reading (operation is only for single band raster)
GDALRasterBandH rasterBand = GDALGetRasterBand( inputDataset, 1 );
if ( rasterBand == nullptr )
if ( !rasterBand )
{
GDALClose( inputDataset );
GDALClose( outputDataset );
Expand All @@ -89,7 +89,7 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p )
mInputNodataValue = GDALGetRasterNoDataValue( rasterBand, nullptr );

GDALRasterBandH outputRasterBand = GDALGetRasterBand( outputDataset, 1 );
if ( outputRasterBand == nullptr )
if ( !outputRasterBand )
{
GDALClose( inputDataset );
GDALClose( outputDataset );
Expand Down Expand Up @@ -209,7 +209,7 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p )
GDALDatasetH QgsNineCellFilter::openInputFile( int& nCellsX, int& nCellsY )
{
GDALDatasetH inputDataset = GDALOpen( TO8F( mInputFile ), GA_ReadOnly );
if ( inputDataset != nullptr )
if ( inputDataset )
{
nCellsX = GDALGetRasterXSize( inputDataset );
nCellsY = GDALGetRasterYSize( inputDataset );
Expand All @@ -231,9 +231,9 @@ GDALDriverH QgsNineCellFilter::openOutputDriver()
//open driver
GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() );

if ( outputDriver == nullptr )
if ( !outputDriver )
{
return outputDriver; //return NULL, driver does not exist
return outputDriver; //return nullptr, driver does not exist
}

driverMetadata = GDALGetMetadata( outputDriver, nullptr );
Expand All @@ -247,7 +247,7 @@ GDALDriverH QgsNineCellFilter::openOutputDriver()

GDALDatasetH QgsNineCellFilter::openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver )
{
if ( inputDataset == nullptr )
if ( !inputDataset )
{
return nullptr;
}
Expand All @@ -258,7 +258,7 @@ GDALDatasetH QgsNineCellFilter::openOutputFile( GDALDatasetH inputDataset, GDALD
//open output file
char **papszOptions = nullptr;
GDALDatasetH outputDataset = GDALCreate( outputDriver, TO8F( mOutputFile ), xSize, ySize, 1, GDT_Float32, papszOptions );
if ( outputDataset == nullptr )
if ( !outputDataset )
{
return outputDataset;
}
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/raster/qgsninecellfilter.h