Skip to content

Commit 8214608

Browse files
committed
more nullptr updates (folloup 320c696)
1 parent c2d919a commit 8214608

File tree

198 files changed

+603
-730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+603
-730
lines changed

src/analysis/interpolation/Node.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ Node& Node::operator=( const Node & n )
3939
if ( n.getPoint() )//mPoint of n is not a null pointer
4040
{
4141
mPoint = new Point3D( n.getPoint()->getX(), n.getPoint()->getY(), n.getPoint()->getZ() );
42-
if ( mPoint == nullptr )//no memory
42+
if ( !mPoint )//no memory
4343
{
4444
mPoint = tmp;
4545
mNext = n.getNext();
4646
return ( *this );
4747
}
4848

4949
}
50-
else//mPoint of n is a null pointer
50+
else//mPoint of n is a nullptr
5151
{
5252
mPoint = nullptr;
5353
}

src/analysis/network/qgsgraphanalyzer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
void QgsGraphAnalyzer::dijkstra( const QgsGraph* source, int startPointIdx, int criterionNum, QVector<int>* resultTree, QVector<double>* resultCost )
3030
{
3131
QVector< double > * result = nullptr;
32-
if ( resultCost != nullptr )
32+
if ( resultCost )
3333
{
3434
result = resultCost;
3535
}
@@ -42,7 +42,7 @@ void QgsGraphAnalyzer::dijkstra( const QgsGraph* source, int startPointIdx, int
4242
result->insert( result->begin(), source->vertexCount(), std::numeric_limits<double>::infinity() );
4343
( *result )[ startPointIdx ] = 0.0;
4444

45-
if ( resultTree != nullptr )
45+
if ( resultTree )
4646
{
4747
resultTree->clear();
4848
resultTree->insert( resultTree->begin(), source->vertexCount(), -1 );
@@ -73,15 +73,15 @@ void QgsGraphAnalyzer::dijkstra( const QgsGraph* source, int startPointIdx, int
7373
if ( cost < ( *result )[ arc.inVertex()] )
7474
{
7575
( *result )[ arc.inVertex()] = cost;
76-
if ( resultTree != nullptr )
76+
if ( resultTree )
7777
{
7878
( *resultTree )[ arc.inVertex()] = *arcIt;
7979
}
8080
not_begin.insert( cost, arc.inVertex() );
8181
}
8282
}
8383
}
84-
if ( resultCost == nullptr )
84+
if ( !resultCost )
8585
{
8686
delete result;
8787
}

src/analysis/network/qgsgraphbuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ QgsGraphBuilder::QgsGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool
2929

3030
QgsGraphBuilder::~QgsGraphBuilder()
3131
{
32-
if ( mGraph != nullptr )
33-
delete mGraph;
32+
delete mGraph;
3433
}
3534

3635
void QgsGraphBuilder::addVertex( int, const QgsPoint& pt )

src/analysis/network/qgslinevectorlayerdirector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void QgsLineVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, c
130130
{
131131
QgsVectorLayer *vl = mVectorLayer;
132132

133-
if ( vl == nullptr )
133+
if ( !vl )
134134
return;
135135

136136
int featureCount = ( int ) vl->featureCount() * 2;

src/analysis/openstreetmap/qgsosmdatabase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ QgsOSMDatabase::~QgsOSMDatabase()
3939

4040
bool QgsOSMDatabase::isOpen() const
4141
{
42-
return mDatabase != nullptr;
42+
return nullptr != mDatabase;
4343
}
4444

4545

@@ -83,7 +83,7 @@ bool QgsOSMDatabase::close()
8383
deleteStatement( mStmtWayNodePoints );
8484
deleteStatement( mStmtWayTags );
8585

86-
Q_ASSERT( mStmtNode == nullptr );
86+
Q_ASSERT( !mStmtNode );
8787

8888
// close database
8989
if ( QgsSLConnect::sqlite3_close( mDatabase ) != SQLITE_OK )

src/analysis/openstreetmap/qgsosmimport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ bool QgsOSMXmlImport::closeDatabase()
232232
deleteStatement( mStmtInsertWayNode );
233233
deleteStatement( mStmtInsertWayTag );
234234

235-
Q_ASSERT( mStmtInsertNode == nullptr );
235+
Q_ASSERT( !mStmtInsertNode );
236236

237237
QgsSLConnect::sqlite3_close( mDatabase );
238238
mDatabase = nullptr;

src/analysis/raster/qgsalignraster.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ bool QgsAlignRaster::createAndWarp( const Item& raster )
458458

459459
// Copy the color table, if required.
460460
GDALColorTableH hCT = GDALGetRasterColorTable( GDALGetRasterBand( hSrcDS, 1 ) );
461-
if ( hCT != nullptr )
461+
if ( hCT )
462462
GDALSetRasterColorTable( GDALGetRasterBand( hDstDS, 1 ), hCT );
463463

464464
// -----------------------------------------------------------------------
@@ -521,7 +521,7 @@ bool QgsAlignRaster::suggestedWarpOutput( const QgsAlignRaster::RasterInfo& info
521521
// Create a transformer that maps from source pixel/line coordinates
522522
// to destination georeferenced coordinates (not destination
523523
// pixel line). We do that by omitting the destination dataset
524-
// handle (setting it to NULL).
524+
// handle (setting it to nullptr).
525525
void* hTransformArg = GDALCreateGenImgProjTransformer( info.mDataset, info.mCrsWkt.toAscii().constData(), nullptr, destWkt.toAscii().constData(), FALSE, 0, 1 );
526526
if ( !hTransformArg )
527527
return false;

src/analysis/raster/qgsalignraster.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ANALYSIS_EXPORT QgsAlignRaster
4949
~RasterInfo();
5050

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

5454
//! Return CRS in WKT format
5555
QString crs() const { return mCrsWkt; }
@@ -138,9 +138,9 @@ class ANALYSIS_EXPORT QgsAlignRaster
138138
virtual ~ProgressHandler() {}
139139
};
140140

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

146146
//! Set list of rasters that will be aligned

src/analysis/raster/qgsninecellfilter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,27 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p )
6060
//open input file
6161
int xSize, ySize;
6262
GDALDatasetH inputDataset = openInputFile( xSize, ySize );
63-
if ( inputDataset == nullptr )
63+
if ( !inputDataset )
6464
{
6565
return 1; //opening of input file failed
6666
}
6767

6868
//output driver
6969
GDALDriverH outputDriver = openOutputDriver();
70-
if ( outputDriver == nullptr )
70+
if ( !outputDriver )
7171
{
7272
return 2;
7373
}
7474

7575
GDALDatasetH outputDataset = openOutputFile( inputDataset, outputDriver );
76-
if ( outputDataset == nullptr )
76+
if ( !outputDataset )
7777
{
7878
return 3; //create operation on output file failed
7979
}
8080

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

9191
GDALRasterBandH outputRasterBand = GDALGetRasterBand( outputDataset, 1 );
92-
if ( outputRasterBand == nullptr )
92+
if ( !outputRasterBand )
9393
{
9494
GDALClose( inputDataset );
9595
GDALClose( outputDataset );
@@ -209,7 +209,7 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p )
209209
GDALDatasetH QgsNineCellFilter::openInputFile( int& nCellsX, int& nCellsY )
210210
{
211211
GDALDatasetH inputDataset = GDALOpen( TO8F( mInputFile ), GA_ReadOnly );
212-
if ( inputDataset != nullptr )
212+
if ( inputDataset )
213213
{
214214
nCellsX = GDALGetRasterXSize( inputDataset );
215215
nCellsY = GDALGetRasterYSize( inputDataset );
@@ -231,9 +231,9 @@ GDALDriverH QgsNineCellFilter::openOutputDriver()
231231
//open driver
232232
GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() );
233233

234-
if ( outputDriver == nullptr )
234+
if ( !outputDriver )
235235
{
236-
return outputDriver; //return NULL, driver does not exist
236+
return outputDriver; //return nullptr, driver does not exist
237237
}
238238

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

248248
GDALDatasetH QgsNineCellFilter::openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver )
249249
{
250-
if ( inputDataset == nullptr )
250+
if ( !inputDataset )
251251
{
252252
return nullptr;
253253
}
@@ -258,7 +258,7 @@ GDALDatasetH QgsNineCellFilter::openOutputFile( GDALDatasetH inputDataset, GDALD
258258
//open output file
259259
char **papszOptions = nullptr;
260260
GDALDatasetH outputDataset = GDALCreate( outputDriver, TO8F( mOutputFile ), xSize, ySize, 1, GDT_Float32, papszOptions );
261-
if ( outputDataset == nullptr )
261+
if ( !outputDataset )
262262
{
263263
return outputDataset;
264264
}

src/analysis/raster/qgsninecellfilter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ class ANALYSIS_EXPORT QgsNineCellFilter
6464
/** Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction*/
6565
GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );
6666
/** Opens the output driver and tests if it supports the creation of a new dataset
67-
@return NULL on error and the driver handle on success*/
67+
@return nullptr on error and the driver handle on success*/
6868
GDALDriverH openOutputDriver();
6969
/** Opens the output file and sets the same geotransform and CRS as the input data
70-
@return the output dataset or NULL in case of error*/
70+
@return the output dataset or nullptr in case of error*/
7171
GDALDatasetH openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
7272

7373
protected:

src/analysis/raster/qgsrastercalcparser.yy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ QgsRasterCalcNode* localParseRasterCalcString(const QString& str, QString& parse
148148
// remove nodes without parents - to prevent memory leaks
149149
while (gTmpNodes.size() > 0)
150150
delete gTmpNodes.takeFirst();
151-
return NULL;
151+
return nullptr;
152152
}
153153
}
154154

src/analysis/raster/qgsrastercalculator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int QgsRasterCalculator::processCalculation( QProgressDialog* p )
106106

107107
//open output dataset for writing
108108
GDALDriverH outputDriver = openOutputDriver();
109-
if ( outputDriver == nullptr )
109+
if ( !outputDriver )
110110
{
111111
return 1;
112112
}
@@ -194,9 +194,9 @@ GDALDriverH QgsRasterCalculator::openOutputDriver()
194194
//open driver
195195
GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() );
196196

197-
if ( outputDriver == nullptr )
197+
if ( !outputDriver )
198198
{
199-
return outputDriver; //return NULL, driver does not exist
199+
return outputDriver; //return nullptr, driver does not exist
200200
}
201201

202202
driverMetadata = GDALGetMetadata( outputDriver, nullptr );
@@ -213,7 +213,7 @@ GDALDatasetH QgsRasterCalculator::openOutputFile( GDALDriverH outputDriver )
213213
//open output file
214214
char **papszOptions = nullptr;
215215
GDALDatasetH outputDataset = GDALCreate( outputDriver, TO8F( mOutputFile ), mNumOutputColumns, mNumOutputRows, 1, GDT_Float32, papszOptions );
216-
if ( outputDataset == nullptr )
216+
if ( !outputDataset )
217217
{
218218
return outputDataset;
219219
}

src/analysis/raster/qgsrastercalculator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ class ANALYSIS_EXPORT QgsRasterCalculator
7979
QgsRasterCalculator();
8080

8181
/** Opens the output driver and tests if it supports the creation of a new dataset
82-
@return NULL on error and the driver handle on success*/
82+
@return nullptr on error and the driver handle on success*/
8383
GDALDriverH openOutputDriver();
8484

8585
/** Opens the output file and sets the same geotransform and CRS as the input data
86-
@return the output dataset or NULL in case of error*/
86+
@return the output dataset or nullptr in case of error*/
8787
GDALDatasetH openOutputFile( GDALDriverH outputDriver );
8888

8989
/** Sets gdal 6 parameters array from mOutputRectangle, mNumOutputColumns, mNumOutputRows

src/analysis/raster/qgsrelief.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,20 @@ int QgsRelief::processRaster( QProgressDialog* p )
8888
//open input file
8989
int xSize, ySize;
9090
GDALDatasetH inputDataset = openInputFile( xSize, ySize );
91-
if ( inputDataset == nullptr )
91+
if ( !inputDataset )
9292
{
9393
return 1; //opening of input file failed
9494
}
9595

9696
//output driver
9797
GDALDriverH outputDriver = openOutputDriver();
98-
if ( outputDriver == nullptr )
98+
if ( !outputDriver )
9999
{
100100
return 2;
101101
}
102102

103103
GDALDatasetH outputDataset = openOutputFile( inputDataset, outputDriver );
104-
if ( outputDataset == nullptr )
104+
if ( !outputDataset )
105105
{
106106
return 3; //create operation on output file failed
107107
}
@@ -125,7 +125,7 @@ int QgsRelief::processRaster( QProgressDialog* p )
125125

126126
//open first raster band for reading (operation is only for single band raster)
127127
GDALRasterBandH rasterBand = GDALGetRasterBand( inputDataset, 1 );
128-
if ( rasterBand == nullptr )
128+
if ( !rasterBand )
129129
{
130130
GDALClose( inputDataset );
131131
GDALClose( outputDataset );
@@ -142,7 +142,7 @@ int QgsRelief::processRaster( QProgressDialog* p )
142142
GDALRasterBandH outputGreenBand = GDALGetRasterBand( outputDataset, 2 );
143143
GDALRasterBandH outputBlueBand = GDALGetRasterBand( outputDataset, 3 );
144144

145-
if ( outputRedBand == nullptr || outputGreenBand == nullptr || outputBlueBand == nullptr )
145+
if ( !outputRedBand || !outputGreenBand || !outputBlueBand )
146146
{
147147
GDALClose( inputDataset );
148148
GDALClose( outputDataset );
@@ -398,7 +398,7 @@ bool QgsRelief::setElevationColor( double elevation, int* red, int* green, int*
398398
GDALDatasetH QgsRelief::openInputFile( int& nCellsX, int& nCellsY )
399399
{
400400
GDALDatasetH inputDataset = GDALOpen( TO8F( mInputFile ), GA_ReadOnly );
401-
if ( inputDataset != nullptr )
401+
if ( inputDataset )
402402
{
403403
nCellsX = GDALGetRasterXSize( inputDataset );
404404
nCellsY = GDALGetRasterYSize( inputDataset );
@@ -420,9 +420,9 @@ GDALDriverH QgsRelief::openOutputDriver()
420420
//open driver
421421
GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() );
422422

423-
if ( outputDriver == nullptr )
423+
if ( !outputDriver )
424424
{
425-
return outputDriver; //return NULL, driver does not exist
425+
return outputDriver; //return nullptr, driver does not exist
426426
}
427427

428428
driverMetadata = GDALGetMetadata( outputDriver, nullptr );
@@ -436,7 +436,7 @@ GDALDriverH QgsRelief::openOutputDriver()
436436

437437
GDALDatasetH QgsRelief::openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver )
438438
{
439-
if ( inputDataset == nullptr )
439+
if ( !inputDataset )
440440
{
441441
return nullptr;
442442
}
@@ -452,7 +452,7 @@ GDALDatasetH QgsRelief::openOutputFile( GDALDatasetH inputDataset, GDALDriverH o
452452

453453
//create three band raster (reg, green, blue)
454454
GDALDatasetH outputDataset = GDALCreate( outputDriver, TO8F( mOutputFile ), xSize, ySize, 3, GDT_Byte, papszOptions );
455-
if ( outputDataset == nullptr )
455+
if ( !outputDataset )
456456
{
457457
return outputDataset;
458458
}
@@ -489,14 +489,14 @@ bool QgsRelief::exportFrequencyDistributionToCsv( const QString& file )
489489
{
490490
int nCellsX, nCellsY;
491491
GDALDatasetH inputDataset = openInputFile( nCellsX, nCellsY );
492-
if ( inputDataset == nullptr )
492+
if ( !inputDataset )
493493
{
494494
return false;
495495
}
496496

497497
//open first raster band for reading (elevation raster is always single band)
498498
GDALRasterBandH elevationBand = GDALGetRasterBand( inputDataset, 1 );
499-
if ( elevationBand == nullptr )
499+
if ( !elevationBand )
500500
{
501501
GDALClose( inputDataset );
502502
return false;
@@ -572,14 +572,14 @@ QList< QgsRelief::ReliefColor > QgsRelief::calculateOptimizedReliefClasses()
572572

573573
int nCellsX, nCellsY;
574574
GDALDatasetH inputDataset = openInputFile( nCellsX, nCellsY );
575-
if ( inputDataset == nullptr )
575+
if ( !inputDataset )
576576
{
577577
return resultList;
578578
}
579579

580580
//open first raster band for reading (elevation raster is always single band)
581581
GDALRasterBandH elevationBand = GDALGetRasterBand( inputDataset, 1 );
582-
if ( elevationBand == nullptr )
582+
if ( !elevationBand )
583583
{
584584
GDALClose( inputDataset );
585585
return resultList;

0 commit comments

Comments
 (0)