Skip to content

Commit

Permalink
0/NULL -> nullptr
Browse files Browse the repository at this point in the history
Using clang-tidy modernize-use-nullptr
  • Loading branch information
nyalldawson committed Sep 11, 2017
1 parent 904aaef commit b20b831
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -8600,7 +8600,7 @@ void QgisApp::layerSubsetString()


if ( !vlayer->vectorJoins().isEmpty() ) 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. " 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. " "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?" ), "Would you like to create a virtual layer out of this layer first?" ),
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsbookmarks.cpp
Expand Up @@ -660,7 +660,7 @@ QAbstractTableModel *QgsMergedBookmarksTableModel::qgisModel()
void QgsMergedBookmarksTableModel::moveBookmark( QAbstractTableModel &modelFrom, QAbstractTableModel &modelTo, int row ) void QgsMergedBookmarksTableModel::moveBookmark( QAbstractTableModel &modelFrom, QAbstractTableModel &modelTo, int row )
{ {
QSqlTableModel *qgisModel = dynamic_cast<QSqlTableModel *>( &modelTo ); QSqlTableModel *qgisModel = dynamic_cast<QSqlTableModel *>( &modelTo );
if ( qgisModel == NULL ) if ( qgisModel == nullptr )
{ {
modelTo.insertRow( -1 ); modelTo.insertRow( -1 );
for ( int column = 1 ; column < modelFrom.columnCount() ; column++ ) for ( int column = 1 ; column < modelFrom.columnCount() ; column++ )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgslayerstylingwidget.cpp
Expand Up @@ -361,7 +361,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
{ {
if ( !mLabelingWidget ) if ( !mLabelingWidget )
{ {
mLabelingWidget = new QgsLabelingWidget( 0, mMapCanvas, mWidgetStack ); mLabelingWidget = new QgsLabelingWidget( nullptr, mMapCanvas, mWidgetStack );
mLabelingWidget->setDockMode( true ); mLabelingWidget->setDockMode( true );
connect( mLabelingWidget, &QgsLabelingWidget::widgetChanged, this, &QgsLayerStylingWidget::autoApply ); connect( mLabelingWidget, &QgsLabelingWidget::widgetChanged, this, &QgsLayerStylingWidget::autoApply );
} }
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsabstractgeometry.cpp
Expand Up @@ -271,6 +271,6 @@ QgsAbstractGeometry *QgsAbstractGeometry::segmentize( double tolerance, Segmenta


QgsAbstractGeometry *QgsAbstractGeometry::toCurveType() const QgsAbstractGeometry *QgsAbstractGeometry::toCurveType() const
{ {
return 0; return nullptr;
} }


2 changes: 1 addition & 1 deletion src/core/layout/qgslayoutitem.cpp
Expand Up @@ -27,7 +27,7 @@


QgsLayoutItem::QgsLayoutItem( QgsLayout *layout ) QgsLayoutItem::QgsLayoutItem( QgsLayout *layout )
: QgsLayoutObject( layout ) : QgsLayoutObject( layout )
, QGraphicsRectItem( 0 ) , QGraphicsRectItem( nullptr )
, mUuid( QUuid::createUuid().toString() ) , mUuid( QUuid::createUuid().toString() )
{ {
setZValue( QgsLayout::ZItem ); setZValue( QgsLayout::ZItem );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgscoordinatetransform_p.cpp
Expand Up @@ -236,7 +236,7 @@ QString QgsCoordinateTransformPrivate::datumTransformString( int datumTransform
QString transformString; QString transformString;


sqlite3 *db = nullptr; 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 ) if ( openResult != SQLITE_OK )
{ {
sqlite3_close( db ); sqlite3_close( db );
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsziputils.cpp
Expand Up @@ -68,7 +68,7 @@ bool QgsZipUtils::unzip( const QString &zipFilename, const QString &dir, QString
int rc = 0; int rc = 0;
struct zip *z = zip_open( zipFilename.toStdString().c_str(), ZIP_CHECKCONS, &rc ); 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 ); int count = zip_get_num_files( z );
if ( count != -1 ) if ( count != -1 )
Expand Down Expand Up @@ -130,7 +130,7 @@ bool QgsZipUtils::zip( const QString &zipFilename, const QStringList &files )
int rc = 0; int rc = 0;
struct zip *z = zip_open( zipFilename.toStdString().c_str(), ZIP_CREATE, &rc ); 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 ) for ( const auto &file : files )
{ {
Expand All @@ -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 ); zip_source *src = zip_source_file( z, file.toStdString().c_str(), 0, 0 );
if ( src != NULL ) if ( src != nullptr )
{ {
#if LIBZIP_VERSION_MAJOR < 1 #if LIBZIP_VERSION_MAJOR < 1
int rc = ( int ) zip_add( z, fileInfo.fileName().toStdString().c_str(), src ); int rc = ( int ) zip_add( z, fileInfo.fileName().toStdString().c_str(), src );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmapcanvastracer.cpp
Expand Up @@ -56,7 +56,7 @@ QgsMapCanvasTracer::~QgsMapCanvasTracer()


QgsMapCanvasTracer *QgsMapCanvasTracer::tracerForCanvas( QgsMapCanvas *canvas ) QgsMapCanvasTracer *QgsMapCanvasTracer::tracerForCanvas( QgsMapCanvas *canvas )
{ {
return sTracers.value( canvas, 0 ); return sTracers.value( canvas, nullptr );
} }


void QgsMapCanvasTracer::reportError( QgsTracer::PathError err, bool addingVertex ) void QgsMapCanvasTracer::reportError( QgsTracer::PathError err, bool addingVertex )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/raster/qgsrasterhistogramwidget.cpp
Expand Up @@ -502,7 +502,7 @@ void QgsRasterHistogramWidget::refreshHistogram()
mypCurve->setPen( QPen( mHistoColors.at( myIteratorInt ) ) ); mypCurve->setPen( QPen( mHistoColors.at( myIteratorInt ) ) );
} }


QwtPlotHistogram *mypHisto = 0; QwtPlotHistogram *mypHisto = nullptr;
if ( ! myDrawLines ) if ( ! myDrawLines )
{ {
mypHisto = new QwtPlotHistogram( tr( "Band %1" ).arg( myIteratorInt ) ); mypHisto = new QwtPlotHistogram( tr( "Band %1" ).arg( myIteratorInt ) );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -1271,7 +1271,7 @@ bool QgsGdalProvider::hasHistogram( int bandNo,
double myMinVal, myMaxVal; double myMinVal, myMaxVal;
int myBinCount; int myBinCount;


GUIntBig *myHistogramArray = 0; GUIntBig *myHistogramArray = nullptr;
CPLErr myError = GDALGetDefaultHistogramEx( myGdalBand, &myMinVal, &myMaxVal, CPLErr myError = GDALGetDefaultHistogramEx( myGdalBand, &myMinVal, &myMaxVal,
&myBinCount, &myHistogramArray, false, &myBinCount, &myHistogramArray, false,
nullptr, nullptr ); nullptr, nullptr );
Expand Down
30 changes: 15 additions & 15 deletions src/providers/ogr/qgsgeopackagedataitems.cpp
Expand Up @@ -344,7 +344,7 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri
QString baseUri = pieces.at( 1 ); QString baseUri = pieces.at( 1 );
QString layerName = pieces.at( 2 ); QString layerName = pieces.at( 2 );
sqlite3 *handle; 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 ) if ( status != SQLITE_OK )
{ {
errCause = sqlite3_errmsg( handle ); errCause = sqlite3_errmsg( handle );
Expand All @@ -365,8 +365,8 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri
status = sqlite3_exec( status = sqlite3_exec(
handle, /* An open database */ handle, /* An open database */
sql, /* SQL to be evaluated */ sql, /* SQL to be evaluated */
NULL, /* Callback function */ nullptr, /* Callback function */
NULL, /* 1st argument to callback */ nullptr, /* 1st argument to callback */
&errmsg /* Error msg written here */ &errmsg /* Error msg written here */
); );
sqlite3_free( sql ); sqlite3_free( sql );
Expand All @@ -382,9 +382,9 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri
( void )sqlite3_exec( ( void )sqlite3_exec(
handle, /* An open database */ handle, /* An open database */
sql, /* SQL to be evaluated */ sql, /* SQL to be evaluated */
NULL, /* Callback function */ nullptr, /* Callback function */
NULL, /* 1st argument to callback */ nullptr, /* 1st argument to callback */
NULL /* Error msg written here */ nullptr /* Error msg written here */
); );
sqlite3_free( sql ); sqlite3_free( sql );
} }
Expand All @@ -395,9 +395,9 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri
( void )sqlite3_exec( ( void )sqlite3_exec(
handle, /* An open database */ handle, /* An open database */
sql, /* SQL to be evaluated */ sql, /* SQL to be evaluated */
NULL, /* Callback function */ nullptr, /* Callback function */
NULL, /* 1st argument to callback */ nullptr, /* 1st argument to callback */
NULL /* Error msg written here */ nullptr /* Error msg written here */
); );
sqlite3_free( sql ); sqlite3_free( sql );
} }
Expand All @@ -407,9 +407,9 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri
( void )sqlite3_exec( ( void )sqlite3_exec(
handle, /* An open database */ handle, /* An open database */
sql, /* SQL to be evaluated */ sql, /* SQL to be evaluated */
NULL, /* Callback function */ nullptr, /* Callback function */
NULL, /* 1st argument to callback */ nullptr, /* 1st argument to callback */
NULL /* Error msg written here */ nullptr /* Error msg written here */
); );
sqlite3_free( sql ); sqlite3_free( sql );
} }
Expand All @@ -418,9 +418,9 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri
( void )sqlite3_exec( ( void )sqlite3_exec(
handle, /* An open database */ handle, /* An open database */
"VACUUM", /* SQL to be evaluated */ "VACUUM", /* SQL to be evaluated */
NULL, /* Callback function */ nullptr, /* Callback function */
NULL, /* 1st argument to callback */ nullptr, /* 1st argument to callback */
NULL /* Error msg written here */ nullptr /* Error msg written here */
); );
} }


Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsgeopackagerasterwriter.cpp
Expand Up @@ -55,7 +55,7 @@ QgsGeoPackageRasterWriter::WriterError QgsGeoPackageRasterWriter::writeRaster( Q
else else
{ {
CPLErrorReset(); CPLErrorReset();
GDALDatasetH hOutDS = GDALTranslate( mOutputUrl.toUtf8().constData(), hSrcDS, psOptions, NULL ); GDALDatasetH hOutDS = GDALTranslate( mOutputUrl.toUtf8().constData(), hSrcDS, psOptions, nullptr );
if ( ! hOutDS ) 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 ); *errorMessage = QObject::tr( "Failed to import layer %1! See the OGR panel in the message logs for details.\n\n" ).arg( mSourceUri.name );
Expand Down
22 changes: 11 additions & 11 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -1448,7 +1448,7 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
break; break;
case QVariant::LongLong: 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" ) ) if ( pszDataTypes && strstr( pszDataTypes, "Integer64" ) )
type = OFTInteger64; type = OFTInteger64;
else else
Expand Down Expand Up @@ -3218,7 +3218,7 @@ void QgsOgrProviderUtils::OGRDestroyWrapper( OGRDataSourceH ogrDataSource )
QString datasetName( QString::fromUtf8( OGR_DS_GetName( ogrDataSource ) ) ); QString datasetName( QString::fromUtf8( OGR_DS_GetName( ogrDataSource ) ) );
if ( ogrDriverName == QLatin1String( "GPKG" ) && if ( ogrDriverName == QLatin1String( "GPKG" ) &&
IsLocalFile( datasetName ) && IsLocalFile( datasetName ) &&
!CPLGetConfigOption( "OGR_SQLITE_JOURNAL", NULL ) ) !CPLGetConfigOption( "OGR_SQLITE_JOURNAL", nullptr ) )
{ {
// We need to reset all iterators on layers, otherwise we will not // We need to reset all iterators on layers, otherwise we will not
// be able to change journal_mode. // be able to change journal_mode.
Expand All @@ -3233,11 +3233,11 @@ void QgsOgrProviderUtils::OGRDestroyWrapper( OGRDataSourceH ogrDataSource )
bool bSuccess = false; bool bSuccess = false;
OGRLayerH hSqlLyr = OGR_DS_ExecuteSQL( ogrDataSource, OGRLayerH hSqlLyr = OGR_DS_ExecuteSQL( ogrDataSource,
"PRAGMA journal_mode = delete", "PRAGMA journal_mode = delete",
NULL, NULL ); nullptr, nullptr );
if ( hSqlLyr != NULL ) if ( hSqlLyr != nullptr )
{ {
OGRFeatureH hFeat = OGR_L_GetNextFeature( hSqlLyr ); OGRFeatureH hFeat = OGR_L_GetNextFeature( hSqlLyr );
if ( hFeat != NULL ) if ( hFeat != nullptr )
{ {
const char *pszRet = OGR_F_GetFieldAsString( hFeat, 0 ); const char *pszRet = OGR_F_GetFieldAsString( hFeat, 0 );
bSuccess = EQUAL( pszRet, "delete" ); bSuccess = EQUAL( pszRet, "delete" );
Expand All @@ -3259,8 +3259,8 @@ void QgsOgrProviderUtils::OGRDestroyWrapper( OGRDataSourceH ogrDataSource )
{ {
QgsDebugMsg( "GPKG: Trying again" ); QgsDebugMsg( "GPKG: Trying again" );
CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "DELETE" ); CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "DELETE" );
ogrDataSource = OGROpen( datasetName.toUtf8().constData(), TRUE, NULL ); ogrDataSource = OGROpen( datasetName.toUtf8().constData(), TRUE, nullptr );
CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", NULL ); CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", nullptr );
if ( ogrDataSource ) if ( ogrDataSource )
{ {
#ifdef QGISDEBUG #ifdef QGISDEBUG
Expand Down Expand Up @@ -3563,7 +3563,7 @@ void QgsOgrProvider::open( OpenMode mode )
{ {
if ( QFileInfo( mFilePath ).suffix().compare( QLatin1String( "gpkg" ), Qt::CaseInsensitive ) == 0 && if ( QFileInfo( mFilePath ).suffix().compare( QLatin1String( "gpkg" ), Qt::CaseInsensitive ) == 0 &&
IsLocalFile( mFilePath ) && IsLocalFile( mFilePath ) &&
!CPLGetConfigOption( "OGR_SQLITE_JOURNAL", NULL ) && !CPLGetConfigOption( "OGR_SQLITE_JOURNAL", nullptr ) &&
QgsSettings().value( QStringLiteral( "qgis/walForSqlite3" ), true ).toBool() ) QgsSettings().value( QStringLiteral( "qgis/walForSqlite3" ), true ).toBool() )
{ {
// For GeoPackage, we force opening of the file in WAL (Write Ahead Log) // For GeoPackage, we force opening of the file in WAL (Write Ahead Log)
Expand All @@ -3574,7 +3574,7 @@ void QgsOgrProvider::open( OpenMode mode )
CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "WAL" ); CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "WAL" );
} }
ogrDataSource = QgsOgrProviderUtils::OGROpenWrapper( mFilePath.toUtf8().constData(), true, &ogrDriver ); ogrDataSource = QgsOgrProviderUtils::OGROpenWrapper( mFilePath.toUtf8().constData(), true, &ogrDriver );
CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", NULL ); CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", nullptr );
} }


mValid = false; mValid = false;
Expand Down Expand Up @@ -4004,7 +4004,7 @@ QGISEXTERN bool saveStyle( const QString &uri, const QString &qmlStyle, const QS
OGRFeatureH hFeature = OGR_L_GetNextFeature( hLayer ); OGRFeatureH hFeature = OGR_L_GetNextFeature( hLayer );
bool bNew = true; bool bNew = true;


if ( hFeature != NULL ) if ( hFeature != nullptr )
{ {
QgsSettings settings; QgsSettings settings;
// Only used in tests. Do not define it for interactive implication // Only used in tests. Do not define it for interactive implication
Expand Down Expand Up @@ -4325,7 +4325,7 @@ QGISEXTERN bool deleteLayer( const QString &uri, QString &errCause )
subsetString, subsetString,
ogrGeometryType ); 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 ( hDS && ( ! layerName.isEmpty() || layerIndex != -1 ) )
{ {
if ( layerIndex == -1 ) if ( layerIndex == -1 )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialiteconnection.cpp
Expand Up @@ -751,7 +751,7 @@ QgsSqliteHandle *QgsSqliteHandle::openDb( const QString &dbPath, bool shared )
return nullptr; return nullptr;
} }
// activating Foreign Key constraints // 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" ); QgsDebugMsg( "Connection to the database was successful" );


Expand Down

0 comments on commit b20b831

Please sign in to comment.