Avoid .get() for boolean checks on unique_ptr

This commit is contained in:
Nyall Dawson 2025-03-27 08:27:35 +10:00
parent 4acbc389e2
commit b744a0ebbb
9 changed files with 10 additions and 10 deletions

View File

@ -3845,7 +3845,7 @@ int QgsGeos::geomDigits( const GEOSGeometry *geom )
{
GEOSContextHandle_t context = QgsGeosContext::get();
geos::unique_ptr bbox( GEOSEnvelope_r( context, geom ) );
if ( !bbox.get() )
if ( !bbox )
return -1;
const GEOSGeometry *bBoxRing = GEOSGetExteriorRing_r( context, bbox.get() );

View File

@ -27,7 +27,7 @@ QgsReportSectionFieldGroup::QgsReportSectionFieldGroup( QgsAbstractReportSection
QString QgsReportSectionFieldGroup::description() const
{
if ( mCoverageLayer.get() )
if ( mCoverageLayer )
return QObject::tr( "Group: %1 - %2" ).arg( mCoverageLayer->name(), mField );
else
return QObject::tr( "Group" );
@ -60,7 +60,7 @@ QgsReportSectionFieldGroup *QgsReportSectionFieldGroup::clone() const
bool QgsReportSectionFieldGroup::beginRender()
{
if ( !mCoverageLayer.get() )
if ( !mCoverageLayer )
return false;
if ( !mField.isEmpty() )

View File

@ -90,7 +90,7 @@ struct StatsProcessor
}
}
if ( !block.get() )
if ( !block )
{
updateFeedback();
return QgsPointCloudStatistics();

View File

@ -263,7 +263,7 @@ QList<QgsEllipsoidUtils::EllipsoidDefinition> QgsEllipsoidUtils::definitions()
while ( char *code = *codesIt )
{
const QgsProjUtils::proj_pj_unique_ptr ellipsoid( proj_create_from_database( context, authority, code, PJ_CATEGORY_ELLIPSOID, 0, nullptr ) );
if ( ellipsoid.get() )
if ( ellipsoid )
{
EllipsoidDefinition def;
QString name = QString( proj_get_name( ellipsoid.get() ) );

View File

@ -224,7 +224,7 @@ void QgsOfflineEditing::synchronize( bool useTransaction )
const QPair<QString, QString> pair( remoteLayer->providerType(), connectionString );
std::shared_ptr<QgsTransactionGroup> transactionGroup = transactionGroups.value( pair );
if ( !transactionGroup.get() )
if ( !transactionGroup )
transactionGroup = std::make_shared<QgsTransactionGroup>();
if ( !transactionGroup->addLayer( remoteLayer.get() ) )

View File

@ -258,7 +258,7 @@ void QgsUserProfileManager::loadUserProfile( const QString &name )
void QgsUserProfileManager::setActiveUserProfile( const QString &profile )
{
if ( ! mUserProfile.get() )
if ( ! mUserProfile )
{
mUserProfile.reset( profileForName( profile ) );
}

View File

@ -1297,7 +1297,7 @@ std::unique_ptr< QgsSymbol > QgsSymbolLayerUtils::loadSymbol( const QDomElement
else
{
std::unique_ptr< QgsSymbolLayer > layer = loadSymbolLayer( e, context );
if ( layer.get() )
if ( layer )
{
// Dealing with sub-symbols nested into a layer
const QDomElement s = e.firstChildElement( QStringLiteral( "symbol" ) );

View File

@ -1442,7 +1442,7 @@ bool QgsVectorLayerProfileGenerator::generateProfileForPolygons()
shiftedPoly.reset( new QgsPolygon( new QgsLineString( newX, newY, newZ ) ) );
intersection.reset( mProfileBufferedCurveEngine->intersection( shiftedPoly.get(), &error ) );
if ( intersection.get() )
if ( intersection )
processTriangleLineIntersect( clampedPolygon.get(), intersection.get(), transformedParts, crossSectionParts );
#ifdef QGISDEBUG
else

View File

@ -946,7 +946,7 @@ QList<QgsColorRampShader::ColorRampItem> QgsWcsProvider::colorTable( int bandNum
Qgis::RasterColorInterpretation QgsWcsProvider::colorInterpretation( int bandNo ) const
{
if ( !mCachedGdalDataset.get() )
if ( !mCachedGdalDataset )
{
return Qgis::RasterColorInterpretation::Undefined;
}