From b20b8316359191692abab6b91609482b8998acbb Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 11 Sep 2017 15:44:04 +1000 Subject: [PATCH] 0/NULL -> nullptr Using clang-tidy modernize-use-nullptr --- src/app/qgisapp.cpp | 2 +- src/app/qgsbookmarks.cpp | 2 +- src/app/qgslayerstylingwidget.cpp | 2 +- src/core/geometry/qgsabstractgeometry.cpp | 2 +- src/core/layout/qgslayoutitem.cpp | 2 +- src/core/qgscoordinatetransform_p.cpp | 2 +- src/core/qgsziputils.cpp | 6 ++-- src/gui/qgsmapcanvastracer.cpp | 2 +- src/gui/raster/qgsrasterhistogramwidget.cpp | 2 +- src/providers/gdal/qgsgdalprovider.cpp | 2 +- src/providers/ogr/qgsgeopackagedataitems.cpp | 30 +++++++++---------- .../ogr/qgsgeopackagerasterwriter.cpp | 2 +- src/providers/ogr/qgsogrprovider.cpp | 22 +++++++------- .../spatialite/qgsspatialiteconnection.cpp | 2 +- 14 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 12b3dfb0a708..9f4bd390c533 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -8600,7 +8600,7 @@ void QgisApp::layerSubsetString() if ( !vlayer->vectorJoins().isEmpty() ) { - if ( QMessageBox::question( NULL, tr( "Filter on joined fields" ), + if ( QMessageBox::question( nullptr, tr( "Filter on joined fields" ), tr( "You are about to set a subset filter on a layer that has joined fields. " "Joined fields cannot be filtered, unless you convert the layer to a virtual layer first. " "Would you like to create a virtual layer out of this layer first?" ), diff --git a/src/app/qgsbookmarks.cpp b/src/app/qgsbookmarks.cpp index 7bd9f798ba70..714ff0033536 100644 --- a/src/app/qgsbookmarks.cpp +++ b/src/app/qgsbookmarks.cpp @@ -660,7 +660,7 @@ QAbstractTableModel *QgsMergedBookmarksTableModel::qgisModel() void QgsMergedBookmarksTableModel::moveBookmark( QAbstractTableModel &modelFrom, QAbstractTableModel &modelTo, int row ) { QSqlTableModel *qgisModel = dynamic_cast( &modelTo ); - if ( qgisModel == NULL ) + if ( qgisModel == nullptr ) { modelTo.insertRow( -1 ); for ( int column = 1 ; column < modelFrom.columnCount() ; column++ ) diff --git a/src/app/qgslayerstylingwidget.cpp b/src/app/qgslayerstylingwidget.cpp index 9352335d4d52..ecdaca3c6155 100644 --- a/src/app/qgslayerstylingwidget.cpp +++ b/src/app/qgslayerstylingwidget.cpp @@ -361,7 +361,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer() { if ( !mLabelingWidget ) { - mLabelingWidget = new QgsLabelingWidget( 0, mMapCanvas, mWidgetStack ); + mLabelingWidget = new QgsLabelingWidget( nullptr, mMapCanvas, mWidgetStack ); mLabelingWidget->setDockMode( true ); connect( mLabelingWidget, &QgsLabelingWidget::widgetChanged, this, &QgsLayerStylingWidget::autoApply ); } diff --git a/src/core/geometry/qgsabstractgeometry.cpp b/src/core/geometry/qgsabstractgeometry.cpp index 8581766abe43..d20939bc07be 100644 --- a/src/core/geometry/qgsabstractgeometry.cpp +++ b/src/core/geometry/qgsabstractgeometry.cpp @@ -271,6 +271,6 @@ QgsAbstractGeometry *QgsAbstractGeometry::segmentize( double tolerance, Segmenta QgsAbstractGeometry *QgsAbstractGeometry::toCurveType() const { - return 0; + return nullptr; } diff --git a/src/core/layout/qgslayoutitem.cpp b/src/core/layout/qgslayoutitem.cpp index 71543c2a6a3f..44386033d3c5 100644 --- a/src/core/layout/qgslayoutitem.cpp +++ b/src/core/layout/qgslayoutitem.cpp @@ -27,7 +27,7 @@ QgsLayoutItem::QgsLayoutItem( QgsLayout *layout ) : QgsLayoutObject( layout ) - , QGraphicsRectItem( 0 ) + , QGraphicsRectItem( nullptr ) , mUuid( QUuid::createUuid().toString() ) { setZValue( QgsLayout::ZItem ); diff --git a/src/core/qgscoordinatetransform_p.cpp b/src/core/qgscoordinatetransform_p.cpp index 72174cb5f2be..6472c0956666 100644 --- a/src/core/qgscoordinatetransform_p.cpp +++ b/src/core/qgscoordinatetransform_p.cpp @@ -236,7 +236,7 @@ QString QgsCoordinateTransformPrivate::datumTransformString( int datumTransform QString transformString; sqlite3 *db = nullptr; - int openResult = sqlite3_open_v2( QgsApplication::srsDatabaseFilePath().toUtf8().constData(), &db, SQLITE_OPEN_READONLY, 0 ); + int openResult = sqlite3_open_v2( QgsApplication::srsDatabaseFilePath().toUtf8().constData(), &db, SQLITE_OPEN_READONLY, nullptr ); if ( openResult != SQLITE_OK ) { sqlite3_close( db ); diff --git a/src/core/qgsziputils.cpp b/src/core/qgsziputils.cpp index 17585a8e327d..b76ecf2bb5e6 100644 --- a/src/core/qgsziputils.cpp +++ b/src/core/qgsziputils.cpp @@ -68,7 +68,7 @@ bool QgsZipUtils::unzip( const QString &zipFilename, const QString &dir, QString int rc = 0; struct zip *z = zip_open( zipFilename.toStdString().c_str(), ZIP_CHECKCONS, &rc ); - if ( rc == ZIP_ER_OK && z != NULL ) + if ( rc == ZIP_ER_OK && z != nullptr ) { int count = zip_get_num_files( z ); if ( count != -1 ) @@ -130,7 +130,7 @@ bool QgsZipUtils::zip( const QString &zipFilename, const QStringList &files ) int rc = 0; struct zip *z = zip_open( zipFilename.toStdString().c_str(), ZIP_CREATE, &rc ); - if ( rc == ZIP_ER_OK && z != NULL ) + if ( rc == ZIP_ER_OK && z != nullptr ) { for ( const auto &file : files ) { @@ -144,7 +144,7 @@ bool QgsZipUtils::zip( const QString &zipFilename, const QStringList &files ) } zip_source *src = zip_source_file( z, file.toStdString().c_str(), 0, 0 ); - if ( src != NULL ) + if ( src != nullptr ) { #if LIBZIP_VERSION_MAJOR < 1 int rc = ( int ) zip_add( z, fileInfo.fileName().toStdString().c_str(), src ); diff --git a/src/gui/qgsmapcanvastracer.cpp b/src/gui/qgsmapcanvastracer.cpp index 9a469cf6669e..0d6ce3c9519d 100644 --- a/src/gui/qgsmapcanvastracer.cpp +++ b/src/gui/qgsmapcanvastracer.cpp @@ -56,7 +56,7 @@ QgsMapCanvasTracer::~QgsMapCanvasTracer() QgsMapCanvasTracer *QgsMapCanvasTracer::tracerForCanvas( QgsMapCanvas *canvas ) { - return sTracers.value( canvas, 0 ); + return sTracers.value( canvas, nullptr ); } void QgsMapCanvasTracer::reportError( QgsTracer::PathError err, bool addingVertex ) diff --git a/src/gui/raster/qgsrasterhistogramwidget.cpp b/src/gui/raster/qgsrasterhistogramwidget.cpp index d9b9639055d8..872c26c4091e 100644 --- a/src/gui/raster/qgsrasterhistogramwidget.cpp +++ b/src/gui/raster/qgsrasterhistogramwidget.cpp @@ -502,7 +502,7 @@ void QgsRasterHistogramWidget::refreshHistogram() mypCurve->setPen( QPen( mHistoColors.at( myIteratorInt ) ) ); } - QwtPlotHistogram *mypHisto = 0; + QwtPlotHistogram *mypHisto = nullptr; if ( ! myDrawLines ) { mypHisto = new QwtPlotHistogram( tr( "Band %1" ).arg( myIteratorInt ) ); diff --git a/src/providers/gdal/qgsgdalprovider.cpp b/src/providers/gdal/qgsgdalprovider.cpp index cc7478a85e8b..fb34097df6c8 100644 --- a/src/providers/gdal/qgsgdalprovider.cpp +++ b/src/providers/gdal/qgsgdalprovider.cpp @@ -1271,7 +1271,7 @@ bool QgsGdalProvider::hasHistogram( int bandNo, double myMinVal, myMaxVal; int myBinCount; - GUIntBig *myHistogramArray = 0; + GUIntBig *myHistogramArray = nullptr; CPLErr myError = GDALGetDefaultHistogramEx( myGdalBand, &myMinVal, &myMaxVal, &myBinCount, &myHistogramArray, false, nullptr, nullptr ); diff --git a/src/providers/ogr/qgsgeopackagedataitems.cpp b/src/providers/ogr/qgsgeopackagedataitems.cpp index d4846cdba2e9..fc66c39794e1 100644 --- a/src/providers/ogr/qgsgeopackagedataitems.cpp +++ b/src/providers/ogr/qgsgeopackagedataitems.cpp @@ -344,7 +344,7 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri QString baseUri = pieces.at( 1 ); QString layerName = pieces.at( 2 ); sqlite3 *handle; - int status = sqlite3_open_v2( baseUri.toUtf8().constData(), &handle, SQLITE_OPEN_READWRITE, NULL ); + int status = sqlite3_open_v2( baseUri.toUtf8().constData(), &handle, SQLITE_OPEN_READWRITE, nullptr ); if ( status != SQLITE_OK ) { errCause = sqlite3_errmsg( handle ); @@ -365,8 +365,8 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri status = sqlite3_exec( handle, /* An open database */ sql, /* SQL to be evaluated */ - NULL, /* Callback function */ - NULL, /* 1st argument to callback */ + nullptr, /* Callback function */ + nullptr, /* 1st argument to callback */ &errmsg /* Error msg written here */ ); sqlite3_free( sql ); @@ -382,9 +382,9 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri ( void )sqlite3_exec( handle, /* An open database */ sql, /* SQL to be evaluated */ - NULL, /* Callback function */ - NULL, /* 1st argument to callback */ - NULL /* Error msg written here */ + nullptr, /* Callback function */ + nullptr, /* 1st argument to callback */ + nullptr /* Error msg written here */ ); sqlite3_free( sql ); } @@ -395,9 +395,9 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri ( void )sqlite3_exec( handle, /* An open database */ sql, /* SQL to be evaluated */ - NULL, /* Callback function */ - NULL, /* 1st argument to callback */ - NULL /* Error msg written here */ + nullptr, /* Callback function */ + nullptr, /* 1st argument to callback */ + nullptr /* Error msg written here */ ); sqlite3_free( sql ); } @@ -407,9 +407,9 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri ( void )sqlite3_exec( handle, /* An open database */ sql, /* SQL to be evaluated */ - NULL, /* Callback function */ - NULL, /* 1st argument to callback */ - NULL /* Error msg written here */ + nullptr, /* Callback function */ + nullptr, /* 1st argument to callback */ + nullptr /* Error msg written here */ ); sqlite3_free( sql ); } @@ -418,9 +418,9 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri ( void )sqlite3_exec( handle, /* An open database */ "VACUUM", /* SQL to be evaluated */ - NULL, /* Callback function */ - NULL, /* 1st argument to callback */ - NULL /* Error msg written here */ + nullptr, /* Callback function */ + nullptr, /* 1st argument to callback */ + nullptr /* Error msg written here */ ); } diff --git a/src/providers/ogr/qgsgeopackagerasterwriter.cpp b/src/providers/ogr/qgsgeopackagerasterwriter.cpp index dd52a1b56e60..2f22c9e95204 100644 --- a/src/providers/ogr/qgsgeopackagerasterwriter.cpp +++ b/src/providers/ogr/qgsgeopackagerasterwriter.cpp @@ -55,7 +55,7 @@ QgsGeoPackageRasterWriter::WriterError QgsGeoPackageRasterWriter::writeRaster( Q else { CPLErrorReset(); - GDALDatasetH hOutDS = GDALTranslate( mOutputUrl.toUtf8().constData(), hSrcDS, psOptions, NULL ); + GDALDatasetH hOutDS = GDALTranslate( mOutputUrl.toUtf8().constData(), hSrcDS, psOptions, nullptr ); if ( ! hOutDS ) { *errorMessage = QObject::tr( "Failed to import layer %1! See the OGR panel in the message logs for details.\n\n" ).arg( mSourceUri.name ); diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index c448d7d1c2aa..f121d64a570d 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -1448,7 +1448,7 @@ bool QgsOgrProvider::addAttributes( const QList &attributes ) break; case QVariant::LongLong: { - const char *pszDataTypes = GDALGetMetadataItem( ogrDriver, GDAL_DMD_CREATIONFIELDDATATYPES, NULL ); + const char *pszDataTypes = GDALGetMetadataItem( ogrDriver, GDAL_DMD_CREATIONFIELDDATATYPES, nullptr ); if ( pszDataTypes && strstr( pszDataTypes, "Integer64" ) ) type = OFTInteger64; else @@ -3218,7 +3218,7 @@ void QgsOgrProviderUtils::OGRDestroyWrapper( OGRDataSourceH ogrDataSource ) QString datasetName( QString::fromUtf8( OGR_DS_GetName( ogrDataSource ) ) ); if ( ogrDriverName == QLatin1String( "GPKG" ) && IsLocalFile( datasetName ) && - !CPLGetConfigOption( "OGR_SQLITE_JOURNAL", NULL ) ) + !CPLGetConfigOption( "OGR_SQLITE_JOURNAL", nullptr ) ) { // We need to reset all iterators on layers, otherwise we will not // be able to change journal_mode. @@ -3233,11 +3233,11 @@ void QgsOgrProviderUtils::OGRDestroyWrapper( OGRDataSourceH ogrDataSource ) bool bSuccess = false; OGRLayerH hSqlLyr = OGR_DS_ExecuteSQL( ogrDataSource, "PRAGMA journal_mode = delete", - NULL, NULL ); - if ( hSqlLyr != NULL ) + nullptr, nullptr ); + if ( hSqlLyr != nullptr ) { OGRFeatureH hFeat = OGR_L_GetNextFeature( hSqlLyr ); - if ( hFeat != NULL ) + if ( hFeat != nullptr ) { const char *pszRet = OGR_F_GetFieldAsString( hFeat, 0 ); bSuccess = EQUAL( pszRet, "delete" ); @@ -3259,8 +3259,8 @@ void QgsOgrProviderUtils::OGRDestroyWrapper( OGRDataSourceH ogrDataSource ) { QgsDebugMsg( "GPKG: Trying again" ); CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "DELETE" ); - ogrDataSource = OGROpen( datasetName.toUtf8().constData(), TRUE, NULL ); - CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", NULL ); + ogrDataSource = OGROpen( datasetName.toUtf8().constData(), TRUE, nullptr ); + CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", nullptr ); if ( ogrDataSource ) { #ifdef QGISDEBUG @@ -3563,7 +3563,7 @@ void QgsOgrProvider::open( OpenMode mode ) { if ( QFileInfo( mFilePath ).suffix().compare( QLatin1String( "gpkg" ), Qt::CaseInsensitive ) == 0 && IsLocalFile( mFilePath ) && - !CPLGetConfigOption( "OGR_SQLITE_JOURNAL", NULL ) && + !CPLGetConfigOption( "OGR_SQLITE_JOURNAL", nullptr ) && QgsSettings().value( QStringLiteral( "qgis/walForSqlite3" ), true ).toBool() ) { // For GeoPackage, we force opening of the file in WAL (Write Ahead Log) @@ -3574,7 +3574,7 @@ void QgsOgrProvider::open( OpenMode mode ) CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "WAL" ); } ogrDataSource = QgsOgrProviderUtils::OGROpenWrapper( mFilePath.toUtf8().constData(), true, &ogrDriver ); - CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", NULL ); + CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", nullptr ); } mValid = false; @@ -4004,7 +4004,7 @@ QGISEXTERN bool saveStyle( const QString &uri, const QString &qmlStyle, const QS OGRFeatureH hFeature = OGR_L_GetNextFeature( hLayer ); bool bNew = true; - if ( hFeature != NULL ) + if ( hFeature != nullptr ) { QgsSettings settings; // Only used in tests. Do not define it for interactive implication @@ -4325,7 +4325,7 @@ QGISEXTERN bool deleteLayer( const QString &uri, QString &errCause ) subsetString, ogrGeometryType ); - OGRDataSourceH hDS = GDALOpenEx( filePath.toLocal8Bit().data(), GDAL_OF_RASTER | GDAL_OF_VECTOR | GDAL_OF_UPDATE, NULL, NULL, NULL ); + OGRDataSourceH hDS = GDALOpenEx( filePath.toLocal8Bit().data(), GDAL_OF_RASTER | GDAL_OF_VECTOR | GDAL_OF_UPDATE, nullptr, nullptr, nullptr ); if ( hDS && ( ! layerName.isEmpty() || layerIndex != -1 ) ) { if ( layerIndex == -1 ) diff --git a/src/providers/spatialite/qgsspatialiteconnection.cpp b/src/providers/spatialite/qgsspatialiteconnection.cpp index 716ef1a70a6f..87356f1d8867 100644 --- a/src/providers/spatialite/qgsspatialiteconnection.cpp +++ b/src/providers/spatialite/qgsspatialiteconnection.cpp @@ -751,7 +751,7 @@ QgsSqliteHandle *QgsSqliteHandle::openDb( const QString &dbPath, bool shared ) return nullptr; } // activating Foreign Key constraints - ( void )sqlite3_exec( sqlite_handle, "PRAGMA foreign_keys = 1", nullptr, 0, nullptr ); + ( void )sqlite3_exec( sqlite_handle, "PRAGMA foreign_keys = 1", nullptr, nullptr, nullptr ); QgsDebugMsg( "Connection to the database was successful" );