mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Cleanup pointer comparisons to nullptr
This commit is contained in:
parent
b20b831635
commit
7afec4bd98
@ -147,7 +147,7 @@ void QgsDwgImporter::startTransaction()
|
||||
|
||||
void QgsDwgImporter::commitTransaction()
|
||||
{
|
||||
Q_ASSERT( mDs != nullptr );
|
||||
Q_ASSERT( mDs );
|
||||
|
||||
if ( mInTransaction && GDALDatasetCommitTransaction( mDs ) != OGRERR_NONE )
|
||||
{
|
||||
@ -1402,7 +1402,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun
|
||||
{
|
||||
size_t i0 = i % vertexnum;
|
||||
|
||||
Q_ASSERT( data.vertlist[i0] != nullptr );
|
||||
Q_ASSERT( data.vertlist[i0] );
|
||||
QgsDebugMsgLevel( QString( "%1: %2,%3 bulge:%4" ).arg( i ).arg( data.vertlist[i0]->x ).arg( data.vertlist[i0]->y ).arg( data.vertlist[i0]->bulge ), 5 );
|
||||
|
||||
QgsPoint p( QgsWkbTypes::PointZ, data.vertlist[i0]->x, data.vertlist[i0]->y, data.elevation );
|
||||
|
@ -660,7 +660,7 @@ QAbstractTableModel *QgsMergedBookmarksTableModel::qgisModel()
|
||||
void QgsMergedBookmarksTableModel::moveBookmark( QAbstractTableModel &modelFrom, QAbstractTableModel &modelTo, int row )
|
||||
{
|
||||
QSqlTableModel *qgisModel = dynamic_cast<QSqlTableModel *>( &modelTo );
|
||||
if ( qgisModel == nullptr )
|
||||
if ( !qgisModel )
|
||||
{
|
||||
modelTo.insertRow( -1 );
|
||||
for ( int column = 1 ; column < modelFrom.columnCount() ; column++ )
|
||||
|
@ -1423,7 +1423,7 @@ Qt::ItemFlags QgsLayerTreeModel::legendNodeFlags( QgsLayerTreeModelLegendNode *n
|
||||
|
||||
bool QgsLayerTreeModel::legendEmbeddedInParent( QgsLayerTreeLayer *nodeLayer ) const
|
||||
{
|
||||
return mLegend[nodeLayer].embeddedNodeInParent != nullptr;
|
||||
return static_cast< bool >( mLegend[nodeLayer].embeddedNodeInParent );
|
||||
}
|
||||
|
||||
QgsLayerTreeModelLegendNode *QgsLayerTreeModel::legendNodeEmbeddedInParent( QgsLayerTreeLayer *nodeLayer ) const
|
||||
|
@ -1194,7 +1194,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
|
||||
}
|
||||
|
||||
LabelPosition *slp = curvedPlacementAtOffset( mapShape, path_distances, orientation, 1, i, reversed, flip );
|
||||
if ( slp == nullptr )
|
||||
if ( !slp )
|
||||
continue;
|
||||
|
||||
// If we placed too many characters upside down
|
||||
@ -1208,7 +1208,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
|
||||
slp = curvedPlacementAtOffset( mapShape, path_distances, orientation, 1, i, reversed, flip );
|
||||
}
|
||||
}
|
||||
if ( slp == nullptr )
|
||||
if ( !slp )
|
||||
continue;
|
||||
|
||||
// evaluate cost
|
||||
|
@ -904,7 +904,7 @@ void QgsGmlStreamingParser::endElement( const XML_Char *el )
|
||||
QgsDebugMsg( "creation of bounding box failed" );
|
||||
}
|
||||
if ( !mCurrentExtent.isNull() && mLayerExtent.isNull() &&
|
||||
mCurrentFeature == nullptr && mFeatureCount == 0 )
|
||||
!mCurrentFeature && mFeatureCount == 0 )
|
||||
{
|
||||
mLayerExtent = mCurrentExtent;
|
||||
mCurrentExtent = QgsRectangle();
|
||||
|
@ -223,7 +223,7 @@ void QgsSQLStatementCollectTableNames::visit( const QgsSQLStatement::NodeTableDe
|
||||
bool QgsSQLStatement::doBasicValidationChecks( QString &errorMsgOut ) const
|
||||
{
|
||||
errorMsgOut.clear();
|
||||
if ( mRootNode == nullptr )
|
||||
if ( !mRootNode )
|
||||
{
|
||||
errorMsgOut = tr( "No root node" );
|
||||
return false;
|
||||
@ -582,7 +582,7 @@ QString QgsSQLStatement::NodeSelect::dump() const
|
||||
ret += ' ';
|
||||
ret += join->dump();
|
||||
}
|
||||
if ( mWhere != nullptr )
|
||||
if ( mWhere )
|
||||
{
|
||||
ret += QLatin1String( " WHERE " );
|
||||
ret += mWhere->dump();
|
||||
@ -619,7 +619,7 @@ QgsSQLStatement::Node *QgsSQLStatement::NodeSelect::clone() const
|
||||
{
|
||||
newSelect->appendJoin( join->cloneThis() );
|
||||
}
|
||||
if ( mWhere != nullptr )
|
||||
if ( mWhere )
|
||||
{
|
||||
newSelect->setWhere( mWhere->clone() );
|
||||
}
|
||||
@ -644,7 +644,7 @@ QString QgsSQLStatement::NodeJoin::dump() const
|
||||
}
|
||||
ret += QLatin1String( "JOIN " );
|
||||
ret += mTableDef->dump();
|
||||
if ( mOnExpr != nullptr )
|
||||
if ( mOnExpr )
|
||||
{
|
||||
ret += QLatin1String( " ON " );
|
||||
ret += mOnExpr->dump();
|
||||
@ -672,7 +672,7 @@ QgsSQLStatement::Node *QgsSQLStatement::NodeJoin::clone() const
|
||||
|
||||
QgsSQLStatement::NodeJoin *QgsSQLStatement::NodeJoin::cloneThis() const
|
||||
{
|
||||
if ( mOnExpr != nullptr )
|
||||
if ( mOnExpr )
|
||||
return new NodeJoin( mTableDef->cloneThis(), mOnExpr->clone(), mType );
|
||||
else
|
||||
return new NodeJoin( mTableDef->cloneThis(), mUsingColumns, mType );
|
||||
|
@ -70,7 +70,7 @@ class CORE_EXPORT QgsTracer : public QObject
|
||||
bool init();
|
||||
|
||||
//! Whether the internal data structures have been initialized
|
||||
bool isInitialized() const { return mGraph != nullptr; }
|
||||
bool isInitialized() const { return static_cast< bool >( mGraph ); }
|
||||
|
||||
//! Whether there was an error during graph creation due to noding exception,
|
||||
//! indicating some input data topology problems
|
||||
|
@ -658,7 +658,7 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected() const
|
||||
|
||||
bool QgsVectorLayer::labelsEnabled() const
|
||||
{
|
||||
return mLabeling != nullptr;
|
||||
return static_cast< bool >( mLabeling );
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::diagramsEnabled() const
|
||||
@ -4251,7 +4251,7 @@ bool QgsVectorLayer::setDependencies( const QSet<QgsMapLayerDependency> &oDeps )
|
||||
Q_FOREACH ( const QgsMapLayerDependency &dep, mDependencies )
|
||||
{
|
||||
QgsVectorLayer *lyr = static_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( dep.layerId() ) );
|
||||
if ( lyr == nullptr )
|
||||
if ( !lyr )
|
||||
continue;
|
||||
disconnect( lyr, &QgsVectorLayer::featureAdded, this, &QgsVectorLayer::dataChanged );
|
||||
disconnect( lyr, &QgsVectorLayer::featureDeleted, this, &QgsVectorLayer::dataChanged );
|
||||
@ -4271,7 +4271,7 @@ bool QgsVectorLayer::setDependencies( const QSet<QgsMapLayerDependency> &oDeps )
|
||||
Q_FOREACH ( const QgsMapLayerDependency &dep, mDependencies )
|
||||
{
|
||||
QgsVectorLayer *lyr = static_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( dep.layerId() ) );
|
||||
if ( lyr == nullptr )
|
||||
if ( !lyr )
|
||||
continue;
|
||||
connect( lyr, &QgsVectorLayer::featureAdded, this, &QgsVectorLayer::dataChanged );
|
||||
connect( lyr, &QgsVectorLayer::featureDeleted, this, &QgsVectorLayer::dataChanged );
|
||||
|
@ -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 != nullptr )
|
||||
if ( rc == ZIP_ER_OK && z )
|
||||
{
|
||||
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 != nullptr )
|
||||
if ( rc == ZIP_ER_OK && z )
|
||||
{
|
||||
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 != nullptr )
|
||||
if ( src )
|
||||
{
|
||||
#if LIBZIP_VERSION_MAJOR < 1
|
||||
int rc = ( int ) zip_add( z, fileInfo.fileName().toStdString().c_str(), src );
|
||||
|
@ -176,7 +176,7 @@ void QgsColorRampButton::showColorRampDialog()
|
||||
|
||||
void QgsColorRampButton::setToDefaultColorRamp()
|
||||
{
|
||||
if ( mDefaultColorRamp == nullptr )
|
||||
if ( !mDefaultColorRamp )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -249,7 +249,7 @@ void QgsColorRampButton::prepareMenu()
|
||||
mMenu->addSeparator();
|
||||
|
||||
//show default color option if set
|
||||
if ( mDefaultColorRamp != nullptr )
|
||||
if ( mDefaultColorRamp )
|
||||
{
|
||||
QAction *defaultColorRampAction = new QAction( tr( "Default color ramp" ), this );
|
||||
defaultColorRampAction->setIcon( createMenuIcon( mDefaultColorRamp ) );
|
||||
@ -509,7 +509,7 @@ void QgsColorRampButton::setRandomColorRamp()
|
||||
void QgsColorRampButton::setButtonBackground( QgsColorRamp *colorramp )
|
||||
{
|
||||
QgsColorRamp *backgroundColorRamp = colorramp;
|
||||
if ( colorramp == nullptr )
|
||||
if ( !colorramp )
|
||||
{
|
||||
backgroundColorRamp = mColorRamp;
|
||||
}
|
||||
@ -625,7 +625,7 @@ bool QgsColorRampButton::showNull() const
|
||||
|
||||
bool QgsColorRampButton::isNull() const
|
||||
{
|
||||
return mColorRamp == nullptr;
|
||||
return !mColorRamp;
|
||||
}
|
||||
|
||||
void QgsColorRampButton::rampWidgetUpdated()
|
||||
|
@ -324,7 +324,7 @@ bool QgsNewGeoPackageLayerDialog::apply()
|
||||
QString tableName( mTableNameEdit->text() );
|
||||
|
||||
bool overwriteTable = false;
|
||||
if ( OGR_DS_GetLayerByName( hDS, tableName.toUtf8().constData() ) != nullptr )
|
||||
if ( OGR_DS_GetLayerByName( hDS, tableName.toUtf8().constData() ) )
|
||||
{
|
||||
if ( property( "hideDialogs" ).toBool() )
|
||||
{
|
||||
@ -389,9 +389,9 @@ bool QgsNewGeoPackageLayerDialog::apply()
|
||||
|
||||
OGRLayerH hLayer = OGR_DS_CreateLayer( hDS, tableName.toUtf8().constData(), hSRS, wkbType, options );
|
||||
CSLDestroy( options );
|
||||
if ( hSRS != nullptr )
|
||||
if ( hSRS )
|
||||
OSRRelease( hSRS );
|
||||
if ( hLayer == nullptr )
|
||||
if ( !hLayer )
|
||||
{
|
||||
QString msg( tr( "Creation of layer failed (OGR error:%1)" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
|
||||
if ( !property( "hideDialogs" ).toBool() )
|
||||
|
@ -268,7 +268,7 @@ void QgsSQLComposerDialog::splitSQLIntoFields()
|
||||
if ( sql.hasParserError() )
|
||||
return;
|
||||
const QgsSQLStatement::NodeSelect *nodeSelect = dynamic_cast<const QgsSQLStatement::NodeSelect *>( sql.rootNode() );
|
||||
if ( nodeSelect == nullptr )
|
||||
if ( !nodeSelect )
|
||||
return;
|
||||
mDistinct = nodeSelect->distinct();
|
||||
QList<QgsSQLStatement::NodeSelectedColumn *> columns = nodeSelect->columns();
|
||||
@ -292,7 +292,7 @@ void QgsSQLComposerDialog::splitSQLIntoFields()
|
||||
|
||||
QString whereText;
|
||||
QgsSQLStatement::Node *where = nodeSelect->where();
|
||||
if ( where != nullptr )
|
||||
if ( where )
|
||||
whereText = where->dump();
|
||||
|
||||
QString orderText;
|
||||
|
@ -112,7 +112,7 @@ QgsArcGisServiceSourceSelect::~QgsArcGisServiceSourceSelect()
|
||||
void QgsArcGisServiceSourceSelect::populateImageEncodings( const QStringList &availableEncodings )
|
||||
{
|
||||
QLayoutItem *item = nullptr;
|
||||
while ( ( item = gbImageEncoding->layout()->takeAt( 0 ) ) != nullptr )
|
||||
while ( ( item = gbImageEncoding->layout()->takeAt( 0 ) ) )
|
||||
{
|
||||
delete item->widget();
|
||||
delete item;
|
||||
|
@ -1201,7 +1201,7 @@ bool QgsOgrProvider::isValid() const
|
||||
// may accept any geometry type)
|
||||
OGRGeometryH QgsOgrProvider::ConvertGeometryIfNecessary( OGRGeometryH hGeom )
|
||||
{
|
||||
if ( hGeom == nullptr )
|
||||
if ( !hGeom )
|
||||
return hGeom;
|
||||
OGRwkbGeometryType layerGeomType = OGR_L_GetGeomType( ogrLayer );
|
||||
OGRwkbGeometryType flattenLayerGeomType = wkbFlatten( layerGeomType );
|
||||
@ -3234,10 +3234,10 @@ void QgsOgrProviderUtils::OGRDestroyWrapper( OGRDataSourceH ogrDataSource )
|
||||
OGRLayerH hSqlLyr = OGR_DS_ExecuteSQL( ogrDataSource,
|
||||
"PRAGMA journal_mode = delete",
|
||||
nullptr, nullptr );
|
||||
if ( hSqlLyr != nullptr )
|
||||
if ( hSqlLyr )
|
||||
{
|
||||
OGRFeatureH hFeat = OGR_L_GetNextFeature( hSqlLyr );
|
||||
if ( hFeat != nullptr )
|
||||
if ( hFeat )
|
||||
{
|
||||
const char *pszRet = OGR_F_GetFieldAsString( hFeat, 0 );
|
||||
bSuccess = EQUAL( pszRet, "delete" );
|
||||
@ -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 != nullptr )
|
||||
if ( hFeature )
|
||||
{
|
||||
QgsSettings settings;
|
||||
// Only used in tests. Do not define it for interactive implication
|
||||
|
@ -204,7 +204,7 @@ QSharedMemory *QgsWFSUtils::createAndAttachSHM()
|
||||
void QgsWFSUtils::init()
|
||||
{
|
||||
QSharedMemory *sharedMemory = createAndAttachSHM();
|
||||
sKeepAliveWorks = sharedMemory != nullptr;
|
||||
sKeepAliveWorks = static_cast< bool >( sharedMemory );
|
||||
delete sharedMemory;
|
||||
|
||||
if ( sKeepAliveWorks )
|
||||
|
@ -117,7 +117,7 @@ void TestQgsConnectionPool::layersFromSameDatasetGPX()
|
||||
{
|
||||
QgsGeometry featureGeom = layer1Features[i].geometry();
|
||||
const QgsPoint *geom = dynamic_cast<const QgsPoint *>( featureGeom.geometry() );
|
||||
QVERIFY( geom != nullptr );
|
||||
QVERIFY( geom );
|
||||
QVERIFY( qFuzzyCompare( geom->x(), i ) );
|
||||
QVERIFY( qFuzzyCompare( geom->y(), i ) );
|
||||
}
|
||||
@ -125,7 +125,7 @@ void TestQgsConnectionPool::layersFromSameDatasetGPX()
|
||||
{
|
||||
QgsGeometry featureGeom = layer2Features[i].geometry();
|
||||
const QgsLineString *geom = dynamic_cast<const QgsLineString *>( featureGeom.geometry() );
|
||||
QVERIFY( geom != nullptr );
|
||||
QVERIFY( geom );
|
||||
int nVtx = geom->vertexCount();
|
||||
QVERIFY( nVtx == nRoutePts );
|
||||
for ( int j = 0; j < nVtx; ++j )
|
||||
|
@ -418,7 +418,7 @@ void TestQgsSQLComposerDialog::testJoins()
|
||||
|
||||
QTableWidget *table = getTableJoins( d );
|
||||
QCOMPARE( table->rowCount(), 1 );
|
||||
QCOMPARE( table->item( 0, 0 ) != nullptr, true );
|
||||
QVERIFY( table->item( 0, 0 ) );
|
||||
table->item( 0, 0 )->setText( QStringLiteral( "join_table" ) );
|
||||
table->item( 0, 1 )->setText( QStringLiteral( "join_expr" ) );
|
||||
|
||||
@ -461,7 +461,7 @@ void TestQgsSQLComposerDialog::testJoins()
|
||||
|
||||
QTest::mouseClick( getAddJoinButton( d ), Qt::LeftButton );
|
||||
QCOMPARE( table->rowCount(), 1 );
|
||||
QCOMPARE( table->item( 0, 0 ) != nullptr, true );
|
||||
QVERIFY( table->item( 0, 0 ) );
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsSQLComposerDialog )
|
||||
|
Loading…
x
Reference in New Issue
Block a user