Skip to content
Permalink
Browse files

more nullptr updates (folloup 320c696)

  • Loading branch information
jef-n committed Dec 16, 2015
1 parent c2d919a commit 8214608169a09358997c882e5a8c0a26513913f1
Showing with 603 additions and 730 deletions.
  1. +2 −2 src/analysis/interpolation/Node.cc
  2. +4 −4 src/analysis/network/qgsgraphanalyzer.cpp
  3. +1 −2 src/analysis/network/qgsgraphbuilder.cpp
  4. +1 −1 src/analysis/network/qgslinevectorlayerdirector.cpp
  5. +2 −2 src/analysis/openstreetmap/qgsosmdatabase.cpp
  6. +1 −1 src/analysis/openstreetmap/qgsosmimport.cpp
  7. +2 −2 src/analysis/raster/qgsalignraster.cpp
  8. +3 −3 src/analysis/raster/qgsalignraster.h
  9. +10 −10 src/analysis/raster/qgsninecellfilter.cpp
  10. +2 −2 src/analysis/raster/qgsninecellfilter.h
  11. +1 −1 src/analysis/raster/qgsrastercalcparser.yy
  12. +4 −4 src/analysis/raster/qgsrastercalculator.cpp
  13. +2 −2 src/analysis/raster/qgsrastercalculator.h
  14. +14 −14 src/analysis/raster/qgsrelief.cpp
  15. +2 −2 src/analysis/raster/qgsrelief.h
  16. +2 −2 src/analysis/vector/qgszonalstatistics.cpp
  17. +1 −1 src/app/legend/qgsapplegendinterface.cpp
  18. +3 −3 src/app/main.cpp
  19. +1 −1 src/app/ogr/qgsnewogrconnection.cpp
  20. +10 −14 src/app/qgisapp.cpp
  21. +6 −6 src/app/qgsattributetabledialog.cpp
  22. +7 −7 src/app/qgsbrowserdockwidget.cpp
  23. +2 −2 src/app/qgsconfigureshortcutsdialog.cpp
  24. +1 −1 src/app/qgscustomization.cpp
  25. +2 −2 src/app/qgscustomprojectiondialog.cpp
  26. +4 −4 src/app/qgsidentifyresultsdialog.cpp
  27. +1 −1 src/app/qgsmaptoolmeasureangle.cpp
  28. +2 −3 src/app/qgsmaptoolselect.cpp
  29. +6 −9 src/app/qgsmaptoolselectfreehand.cpp
  30. +3 −4 src/app/qgsmaptoolselectpolygon.cpp
  31. +5 −8 src/app/qgsmaptoolselectradius.cpp
  32. +1 −1 src/app/qgsmaptoolselectrectangle.cpp
  33. +4 −8 src/app/qgsmaptoolselectutils.cpp
  34. +1 −1 src/app/qgsmaptoolselectutils.h
  35. +1 −1 src/app/qgsoptions.cpp
  36. +1 −1 src/app/qgspluginregistry.cpp
  37. +1 −1 src/app/qgsprojectlayergroupdialog.cpp
  38. +5 −4 src/app/qgsrasterlayerproperties.cpp
  39. +1 −1 src/app/qgstipgui.cpp
  40. +4 −4 src/app/qgsundowidget.cpp
  41. +4 −4 src/core/auth/qgsauthmethodregistry.h
  42. +1 −1 src/core/effects/qgspainteffectregistry.cpp
  43. +4 −4 src/core/effects/qgspainteffectregistry.h
  44. +1 −1 src/core/geometry/qgscurvepolygonv2.cpp
  45. +1 −1 src/core/geometry/qgscurvepolygonv2.h
  46. +1 −1 src/core/geometry/qgsgeometry.cpp
  47. +1 −1 src/core/geometry/qgsgeometry.h
  48. +2 −2 src/core/geometry/qgsgeos.cpp
  49. +1 −1 src/core/geometry/qgspolygonv2.cpp
  50. +1 −1 src/core/layertree/qgslayertreemodel.cpp
  51. +1 −1 src/core/layertree/qgslayertreenode.cpp
  52. +2 −2 src/core/pal/feature.cpp
  53. +1 −1 src/core/pal/labelposition.cpp
  54. +3 −3 src/core/pal/layer.cpp
  55. +2 −2 src/core/pal/pal.cpp
  56. +1 −1 src/core/pal/problem.cpp
  57. +2 −2 src/core/qgis.cpp
  58. +1 −1 src/core/qgsbrowsermodel.cpp
  59. +1 −1 src/core/qgscolorschemeregistry.cpp
  60. +2 −2 src/core/qgscoordinatetransform.cpp
  61. +2 −2 src/core/qgsdataitem.cpp
  62. +4 −4 src/core/qgsexpressionparser.yy
  63. +1 −1 src/core/qgsfeatureiterator.cpp
  64. +2 −2 src/core/qgsgml.cpp
  65. +1 −1 src/core/qgsgmlschema.cpp
  66. +1 −1 src/core/qgslabel.cpp
  67. +1 −1 src/core/qgsmaplayer.h
  68. +1 −1 src/core/qgsmaplayerregistry.h
  69. +1 −1 src/core/qgsmaprenderer.cpp
  70. +2 −2 src/core/qgsmaprenderer.h
  71. +1 −1 src/core/qgsmaprendererjob.cpp
  72. +4 −4 src/core/qgsmaprenderersequentialjob.cpp
  73. +1 −1 src/core/qgsmapsettings.cpp
  74. +7 −21 src/core/qgsofflineediting.cpp
  75. +3 −3 src/core/qgspallabeling.cpp
  76. +3 −2 src/core/qgspluginlayerregistry.cpp
  77. +2 −2 src/core/qgspointlocator.cpp
  78. +1 −1 src/core/qgspythonrunner.cpp
  79. +2 −2 src/core/qgsrelation.cpp
  80. +3 −3 src/core/qgsrendercontext.h
  81. +1 −1 src/core/qgsrunprocess.cpp
  82. +1 −1 src/core/qgsspatialindex.cpp
  83. +1 −35 src/core/qgstransaction.cpp
  84. +2 −2 src/core/qgsvectorfilewriter.cpp
  85. +1 −1 src/core/qgsvectorlayer.cpp
  86. +3 −3 src/core/qgsvectorlayercache.cpp
  87. +3 −4 src/core/qgsvectorlayerdiagramprovider.cpp
  88. +1 −1 src/core/qgsvectorlayerfeatureiterator.cpp
  89. +2 −8 src/core/qgsvectorlayerimport.cpp
  90. +1 −1 src/core/qgsvectorlayerrenderer.cpp
  91. +4 −4 src/core/raster/qgscontrastenhancement.cpp
  92. +11 −11 src/core/raster/qgsrasterblock.cpp
  93. +5 −5 src/core/raster/qgsrastershader.cpp
  94. +3 −3 src/core/symbology-ng/qgscptcityarchive.cpp
  95. +1 −1 src/core/symbology-ng/qgsfillsymbollayerv2.cpp
  96. +1 −1 src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
  97. +2 −2 src/core/symbology-ng/qgslinesymbollayerv2.cpp
  98. +5 −5 src/core/symbology-ng/qgsrendererv2.cpp
  99. +1 −1 src/core/symbology-ng/qgsrendererv2registry.cpp
  100. +1 −1 src/core/symbology-ng/qgsrulebasedrendererv2.cpp
  101. +1 −1 src/core/symbology-ng/qgsstylev2.cpp
  102. +1 −1 src/core/symbology-ng/qgssymbollayerv2registry.cpp
  103. +3 −3 src/core/symbology-ng/qgssymbollayerv2utils.cpp
  104. +6 −5 src/core/symbology-ng/qgssymbolv2.cpp
  105. +1 −1 src/gui/attributetable/qgsattributetabledelegate.cpp
  106. +4 −7 src/gui/editorwidgets/qgsrelationreferencewidget.cpp
  107. +4 −4 src/gui/effects/qgspainteffectpropertieswidget.cpp
  108. +1 −1 src/gui/effects/qgspainteffectwidget.cpp
  109. +7 −8 src/gui/layertree/qgslayertreemapcanvasbridge.cpp
  110. +2 −2 src/gui/qgsattributetypeloaddialog.cpp
  111. +2 −2 src/gui/qgscollapsiblegroupbox.cpp
  112. +1 −1 src/gui/qgscomposerview.cpp
  113. +1 −1 src/gui/qgsexpressionbuilderwidget.cpp
  114. +3 −3 src/gui/qgsidentifymenu.h
  115. +10 −27 src/gui/qgsmapcanvas.cpp
  116. +1 −1 src/gui/qgsmaplayeractionregistry.cpp
  117. +1 −1 src/gui/qgsmessagebar.cpp
  118. +6 −6 src/gui/qgsmessagebaritem.cpp
  119. +1 −1 src/gui/qgssublayersdialog.cpp
  120. +8 −10 src/gui/raster/qgsrasterhistogramwidget.cpp
  121. +1 −1 src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp
  122. +3 −3 src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
  123. +1 −1 src/gui/symbology-ng/qgsheatmaprendererwidget.cpp
  124. +4 −4 src/gui/symbology-ng/qgslayerpropertieswidget.cpp
  125. +4 −4 src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
  126. +3 −3 src/gui/symbology-ng/qgsrendererv2widget.cpp
  127. +1 −1 src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
  128. +1 −1 src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp
  129. +2 −2 src/gui/symbology-ng/qgssymbollayerv2widget.cpp
  130. +4 −4 src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
  131. +1 −2 src/plugins/coordinate_capture/coordinatecapturemaptool.cpp
  132. +6 −6 src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.cpp
  133. +12 −12 src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp
  134. +2 −2 src/plugins/evis/evis.cpp
  135. +4 −4 src/plugins/evis/idtool/eviseventidtool.cpp
  136. +4 −7 src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.cpp
  137. +1 −1 src/plugins/geometry_checker/utils/qgsfeaturepool.cpp
  138. +4 −6 src/plugins/geometry_snapper/qgsgeometrysnapperdialog.cpp
  139. +4 −9 src/plugins/georeferencer/qgsgeoreftransform.cpp
  140. +1 −1 src/plugins/georeferencer/qgsmapcoordsdialog.cpp
  141. +1 −1 src/plugins/georeferencer/qgsrasterchangecoords.cpp
  142. +3 −3 src/plugins/globe/globe_plugin.cpp
  143. +2 −2 src/plugins/globe/globe_plugin.h
  144. +1 −1 src/plugins/globe/globe_plugin_dialog.cpp
  145. +2 −2 src/plugins/globe/qgsosgearthtilesource.h
  146. +1 −1 src/plugins/gps_importer/qgsgpsdevicedialog.cpp
  147. +1 −1 src/plugins/grass/qgsgrassmodule.cpp
  148. +4 −4 src/plugins/grass/qgsgrassnewmapset.cpp
  149. +1 −1 src/plugins/heatmap/heatmap.cpp
  150. +1 −1 src/plugins/oracle_raster/qgsselectgeoraster_ui.cpp
  151. +1 −1 src/plugins/raster_terrain_analysis/qgsrasterterrainanalysisdialog.cpp
  152. +1 −1 src/plugins/roadgraph/exportdlg.cpp
  153. +1 −1 src/plugins/roadgraph/linevectorlayersettings.cpp
  154. +5 −2 src/plugins/roadgraph/roadgraphplugin.cpp
  155. +4 −4 src/plugins/roadgraph/shortestpathwidget.cpp
  156. +4 −13 src/plugins/spatialquery/qgsspatialquery.cpp
  157. +1 −1 src/providers/delimitedtext/qgsdelimitedtextfile.cpp
  158. +2 −2 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  159. +16 −16 src/providers/gdal/qgsgdalprovider.cpp
  160. +3 −3 src/providers/gpx/gpsdata.cpp
  161. +6 −8 src/providers/gpx/qgsgpxprovider.cpp
  162. +1 −1 src/providers/grass/qgis.d.rast.c
  163. +12 −12 src/providers/grass/qgis.v.in.cpp
  164. +2 −2 src/providers/grass/qgsgrass.cpp
  165. +1 −1 src/providers/grass/qgsgrassdatafile.cpp
  166. +14 −14 src/providers/grass/qgsgrassgislib.cpp
  167. +6 −6 src/providers/ogr/qgsogrgeometrysimplifier.cpp
  168. +7 −7 src/providers/ogr/qgsogrprovider.cpp
  169. +3 −3 src/providers/oracle/qgsoraclesourceselect.h
  170. +3 −3 src/providers/oracle/qgsoracletablecache.cpp
  171. +12 −20 src/providers/spatialite/qgsspatialiteconnection.cpp
  172. +1 −1 src/providers/spatialite/qgsspatialitefeatureiterator.cpp
  173. +32 −41 src/providers/spatialite/qgsspatialiteprovider.cpp
  174. +2 −2 src/providers/spatialite/qspatialite/qsql_spatialite.cpp
  175. +1 −1 src/providers/wcs/qgswcsprovider.cpp
  176. +2 −2 src/providers/wms/qgswmsprovider.cpp
  177. +10 −9 src/python/qgspythonutilsimpl.cpp
  178. +1 −1 src/server/qgsmsutils.cpp
  179. +1 −1 src/server/qgsowsserver.cpp
  180. +11 −11 src/server/qgsserver.cpp
  181. +1 −1 src/server/qgsserverlogger.cpp
  182. +7 −7 src/server/qgssldconfigparser.cpp
  183. +2 −2 src/server/qgswmsserver.cpp
  184. +1 −1 tests/bench/qgsbench.cpp
  185. +3 −3 tests/src/analysis/testqgszonalstatistics.cpp
  186. +1 −1 tests/src/app/testqgisappclipboard.cpp
  187. +1 −1 tests/src/core/qgscompositionchecker.cpp
  188. +1 −1 tests/src/core/regression992.cpp
  189. +1 −1 tests/src/core/testqgsdataitem.cpp
  190. +2 −2 tests/src/core/testqgsexpression.cpp
  191. +5 −5 tests/src/core/testqgsgeometry.cpp
  192. +1 −1 tests/src/core/testqgsimageoperation.cpp
  193. +1 −1 tests/src/core/testqgsinvertedpolygonrenderer.cpp
  194. +1 −1 tests/src/core/testqgspainteffectregistry.cpp
  195. +1 −1 tests/src/core/testqgsrastersublayer.cpp
  196. +4 −4 tests/src/core/testqgsrulebasedrenderer.cpp
  197. +1 −1 tests/src/core/testqgsstylev2.cpp
  198. +7 −7 tests/src/core/testziplayer.cpp
@@ -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;
}
@@ -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;
}
@@ -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 );
@@ -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;
}
@@ -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 )
@@ -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;
@@ -39,7 +39,7 @@ QgsOSMDatabase::~QgsOSMDatabase()

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


@@ -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 )
@@ -232,7 +232,7 @@ bool QgsOSMXmlImport::closeDatabase()
deleteStatement( mStmtInsertWayNode );
deleteStatement( mStmtInsertWayTag );

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

QgsSLConnect::sqlite3_close( mDatabase );
mDatabase = nullptr;
@@ -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 );

// -----------------------------------------------------------------------
@@ -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;
@@ -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; }
@@ -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
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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 );
@@ -247,7 +247,7 @@ GDALDriverH QgsNineCellFilter::openOutputDriver()

GDALDatasetH QgsNineCellFilter::openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver )
{
if ( inputDataset == nullptr )
if ( !inputDataset )
{
return nullptr;
}
@@ -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;
}
@@ -64,10 +64,10 @@ class ANALYSIS_EXPORT QgsNineCellFilter
/** Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction*/
GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );
/** Opens the output driver and tests if it supports the creation of a new dataset
@return NULL on error and the driver handle on success*/
@return nullptr on error and the driver handle on success*/
GDALDriverH openOutputDriver();
/** Opens the output file and sets the same geotransform and CRS as the input data
@return the output dataset or NULL in case of error*/
@return the output dataset or nullptr in case of error*/
GDALDatasetH openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );

protected:
@@ -148,7 +148,7 @@ QgsRasterCalcNode* localParseRasterCalcString(const QString& str, QString& parse
// remove nodes without parents - to prevent memory leaks
while (gTmpNodes.size() > 0)
delete gTmpNodes.takeFirst();
return NULL;
return nullptr;
}
}

@@ -106,7 +106,7 @@ int QgsRasterCalculator::processCalculation( QProgressDialog* p )

//open output dataset for writing
GDALDriverH outputDriver = openOutputDriver();
if ( outputDriver == nullptr )
if ( !outputDriver )
{
return 1;
}
@@ -194,9 +194,9 @@ GDALDriverH QgsRasterCalculator::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 );
@@ -213,7 +213,7 @@ GDALDatasetH QgsRasterCalculator::openOutputFile( GDALDriverH outputDriver )
//open output file
char **papszOptions = nullptr;
GDALDatasetH outputDataset = GDALCreate( outputDriver, TO8F( mOutputFile ), mNumOutputColumns, mNumOutputRows, 1, GDT_Float32, papszOptions );
if ( outputDataset == nullptr )
if ( !outputDataset )
{
return outputDataset;
}
@@ -79,11 +79,11 @@ class ANALYSIS_EXPORT QgsRasterCalculator
QgsRasterCalculator();

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

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

/** Sets gdal 6 parameters array from mOutputRectangle, mNumOutputColumns, mNumOutputRows
@@ -88,20 +88,20 @@ int QgsRelief::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
}
@@ -125,7 +125,7 @@ int QgsRelief::processRaster( QProgressDialog* p )

//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 );
@@ -142,7 +142,7 @@ int QgsRelief::processRaster( QProgressDialog* p )
GDALRasterBandH outputGreenBand = GDALGetRasterBand( outputDataset, 2 );
GDALRasterBandH outputBlueBand = GDALGetRasterBand( outputDataset, 3 );

if ( outputRedBand == nullptr || outputGreenBand == nullptr || outputBlueBand == nullptr )
if ( !outputRedBand || !outputGreenBand || !outputBlueBand )
{
GDALClose( inputDataset );
GDALClose( outputDataset );
@@ -398,7 +398,7 @@ bool QgsRelief::setElevationColor( double elevation, int* red, int* green, int*
GDALDatasetH QgsRelief::openInputFile( int& nCellsX, int& nCellsY )
{
GDALDatasetH inputDataset = GDALOpen( TO8F( mInputFile ), GA_ReadOnly );
if ( inputDataset != nullptr )
if ( inputDataset )
{
nCellsX = GDALGetRasterXSize( inputDataset );
nCellsY = GDALGetRasterYSize( inputDataset );
@@ -420,9 +420,9 @@ GDALDriverH QgsRelief::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 );
@@ -436,7 +436,7 @@ GDALDriverH QgsRelief::openOutputDriver()

GDALDatasetH QgsRelief::openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver )
{
if ( inputDataset == nullptr )
if ( !inputDataset )
{
return nullptr;
}
@@ -452,7 +452,7 @@ GDALDatasetH QgsRelief::openOutputFile( GDALDatasetH inputDataset, GDALDriverH o

//create three band raster (reg, green, blue)
GDALDatasetH outputDataset = GDALCreate( outputDriver, TO8F( mOutputFile ), xSize, ySize, 3, GDT_Byte, papszOptions );
if ( outputDataset == nullptr )
if ( !outputDataset )
{
return outputDataset;
}
@@ -489,14 +489,14 @@ bool QgsRelief::exportFrequencyDistributionToCsv( const QString& file )
{
int nCellsX, nCellsY;
GDALDatasetH inputDataset = openInputFile( nCellsX, nCellsY );
if ( inputDataset == nullptr )
if ( !inputDataset )
{
return false;
}

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

int nCellsX, nCellsY;
GDALDatasetH inputDataset = openInputFile( nCellsX, nCellsY );
if ( inputDataset == nullptr )
if ( !inputDataset )
{
return resultList;
}

//open first raster band for reading (elevation raster is always single band)
GDALRasterBandH elevationBand = GDALGetRasterBand( inputDataset, 1 );
if ( elevationBand == nullptr )
if ( !elevationBand )
{
GDALClose( inputDataset );
return resultList;

1 comment on commit 8214608

@nyalldawson

This comment has been minimized.

Copy link
Collaborator

@nyalldawson nyalldawson commented on 8214608 Dec 16, 2015

@jef-n love it! Thanks!

Please sign in to comment.
You can’t perform that action at this time.