Skip to content
Permalink
Browse files

0/NULL -> nullptr

Using clang-tidy modernize-use-nullptr
  • Loading branch information
nyalldawson committed Sep 11, 2017
1 parent 904aaef commit b20b8316359191692abab6b91609482b8998acbb
@@ -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?" ),
@@ -660,7 +660,7 @@ QAbstractTableModel *QgsMergedBookmarksTableModel::qgisModel()
void QgsMergedBookmarksTableModel::moveBookmark( QAbstractTableModel &modelFrom, QAbstractTableModel &modelTo, int row )
{
QSqlTableModel *qgisModel = dynamic_cast<QSqlTableModel *>( &modelTo );
if ( qgisModel == NULL )
if ( qgisModel == nullptr )
{
modelTo.insertRow( -1 );
for ( int column = 1 ; column < modelFrom.columnCount() ; column++ )
@@ -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 );
}
@@ -271,6 +271,6 @@ QgsAbstractGeometry *QgsAbstractGeometry::segmentize( double tolerance, Segmenta

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

@@ -27,7 +27,7 @@

QgsLayoutItem::QgsLayoutItem( QgsLayout *layout )
: QgsLayoutObject( layout )
, QGraphicsRectItem( 0 )
, QGraphicsRectItem( nullptr )
, mUuid( QUuid::createUuid().toString() )
{
setZValue( QgsLayout::ZItem );
@@ -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 );
@@ -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 );
@@ -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 )
@@ -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 ) );
@@ -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 );
@@ -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 */
);
}

@@ -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 );
@@ -1448,7 +1448,7 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &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 )
@@ -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" );

0 comments on commit b20b831

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