Skip to content

Commit

Permalink
Merge pull request qgis#59813 from nyalldawson/coverity
Browse files Browse the repository at this point in the history
Coverity scan fixes
  • Loading branch information
alexbruy authored Dec 11, 2024
2 parents 992ccc9 + 737db66 commit 0baab44
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 35 deletions.
3 changes: 2 additions & 1 deletion python/PyQt6/core/auto_generated/qgsrelation.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ which is referenced by the provided feature.

:param feature: A feature from the referencing (child) layer

:return: A request the referenced feature
:return: The referenced (parent) feature, or an invalid feature if no matching feature
was found
%End

QString name() const;
Expand Down
3 changes: 2 additions & 1 deletion python/core/auto_generated/qgsrelation.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ which is referenced by the provided feature.

:param feature: A feature from the referencing (child) layer

:return: A request the referenced feature
:return: The referenced (parent) feature, or an invalid feature if no matching feature
was found
%End

QString name() const;
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/processing/qgsalgorithmexportmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,8 @@ QVariantMap QgsMeshContoursAlgorithm::processAlgorithm( const QVariantMap &param
lineFeat.setGeometry( line );
lineFeat.setAttributes( lineAttributes );

sinkLines->addFeature( lineFeat );
if ( !sinkLines->addFeature( lineFeat, QgsFeatureSink::FastInsert ) )
throw QgsProcessingException( writeFeatureError( sinkLines.get(), parameters, QStringLiteral( "OUTPUT_LINES" ) ) );
}

for ( int l = 0; l < mLevels.count() - 1; ++l )
Expand Down
8 changes: 5 additions & 3 deletions src/analysis/processing/qgsalgorithmgltftovector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ QVariantMap QgsGltfToVectorFeaturesAlgorithm::processAlgorithm( const QVariantMa

const QgsVector3D tileTranslationEcef = QgsGltfUtils::extractTileTranslation( model );
std::function<void( int nodeIndex, const QMatrix4x4 &transform )> traverseNode;
traverseNode = [&model, feedback, &polygonSink, &lineSink, &warnedPrimitiveTypes, &ecefTransform, &tileTranslationEcef, &traverseNode]( int nodeIndex, const QMatrix4x4 &parentTransform ) {
traverseNode = [&model, feedback, &polygonSink, &lineSink, &warnedPrimitiveTypes, &ecefTransform, &tileTranslationEcef, &traverseNode, &parameters]( int nodeIndex, const QMatrix4x4 &parentTransform ) {
const tinygltf::Node &gltfNode = model.nodes[nodeIndex];
std::unique_ptr<QMatrix4x4> gltfLocalTransform = QgsGltfUtils::parseNodeTransform( gltfNode );
if ( !parentTransform.isIdentity() )
Expand Down Expand Up @@ -361,7 +361,8 @@ QVariantMap QgsGltfToVectorFeaturesAlgorithm::processAlgorithm( const QVariantMa
{
QgsFeature f;
f.setGeometry( std::move( geometry ) );
polygonSink->addFeature( f, QgsFeatureSink::FastInsert );
if ( !polygonSink->addFeature( f, QgsFeatureSink::FastInsert ) )
throw QgsProcessingException( writeFeatureError( polygonSink.get(), parameters, QStringLiteral( "OUTPUT_POLYGONS" ) ) );
}
}
break;
Expand All @@ -376,7 +377,8 @@ QVariantMap QgsGltfToVectorFeaturesAlgorithm::processAlgorithm( const QVariantMa
{
QgsFeature f;
f.setGeometry( std::move( geometry ) );
lineSink->addFeature( f, QgsFeatureSink::FastInsert );
if ( !lineSink->addFeature( f, QgsFeatureSink::FastInsert ) )
throw QgsProcessingException( writeFeatureError( lineSink.get(), parameters, QStringLiteral( "OUTPUT_LINES" ) ) );
}
}
break;
Expand Down
9 changes: 6 additions & 3 deletions src/analysis/processing/qgsalgorithmjoinbylocationsummary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ QVariantMap QgsJoinByLocationSummaryAlgorithm::processAlgorithm( const QVariantM
// features will have incorrect attribute length
// and provider may reject them
f.resizeAttributes( outputFields.size() );
sink->addFeature( f, QgsFeatureSink::FastInsert );
if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
throw QgsProcessingException( writeFeatureError( sink.get(), parameters, QStringLiteral( "OUTPUT" ) ) );
}
continue;
}
Expand Down Expand Up @@ -365,7 +366,8 @@ QVariantMap QgsJoinByLocationSummaryAlgorithm::processAlgorithm( const QVariantM
// features will have incorrect attribute length
// and provider may reject them
f.resizeAttributes( outputFields.size() );
sink->addFeature( f, QgsFeatureSink::FastInsert );
if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
throw QgsProcessingException( writeFeatureError( sink.get(), parameters, QStringLiteral( "OUTPUT" ) ) );
}
}
else
Expand Down Expand Up @@ -543,7 +545,8 @@ QVariantMap QgsJoinByLocationSummaryAlgorithm::processAlgorithm( const QVariantM
}

f.setAttributes( outputAttributes );
sink->addFeature( f, QgsFeatureSink::FastInsert );
if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
throw QgsProcessingException( writeFeatureError( sink.get(), parameters, QStringLiteral( "OUTPUT" ) ) );
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/analysis/processing/qgsalgorithmrastersampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ QVariantMap QgsRasterSamplingAlgorithm::processAlgorithm( const QVariantMap &par
{
attributes += emptySampleAttributes;
outputFeature.setAttributes( attributes );
sink->addFeature( outputFeature, QgsFeatureSink::FastInsert );
if ( !sink->addFeature( outputFeature, QgsFeatureSink::FastInsert ) )
throw QgsProcessingException( writeFeatureError( sink.get(), parameters, QStringLiteral( "OUTPUT" ) ) );
feedback->reportError( QObject::tr( "No geometry attached to feature %1." ).arg( feature.id() ) );
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/processing/qgsalgorithmshortestline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ QVariantMap QgsShortestLineAlgorithm::processAlgorithm( const QVariantMap &param

f.setAttributes( attrs );
f.setGeometry( shortestLine );
sink->addFeature( f, QgsFeatureSink::FastInsert );
if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
throw QgsProcessingException( writeFeatureError( sink.get(), parameters, QStringLiteral( "OUTPUT" ) ) );
}

i++;
Expand Down
2 changes: 1 addition & 1 deletion src/auth/oauth2/core/qgsauthoauth2method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ QgsO2 *QgsOAuth2Factory::createO2Private( const QString &authcfg, QgsAuthOAuth2C
{
oauth2config->moveToThread( nullptr );
#ifndef __clang_analyzer__
QMetaObject::invokeMethod( this, createO2InThread, Qt::BlockingQueuedConnection );
QMetaObject::invokeMethod( this, std::move( createO2InThread ), Qt::BlockingQueuedConnection );
#endif
}
Q_ASSERT( o2->thread() == this );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsrelation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ QgsFeature QgsRelation::getReferencedFeature( const QgsFeature &feature ) const
QgsFeatureRequest request = getReferencedFeatureRequest( feature );

QgsFeature f;
d->mReferencedLayer->getFeatures( request ).nextFeature( f );
( void )d->mReferencedLayer->getFeatures( request ).nextFeature( f );
return f;
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsrelation.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ class CORE_EXPORT QgsRelation
*
* \param feature A feature from the referencing (child) layer
*
* \returns A request the referenced feature
* \returns The referenced (parent) feature, or an invalid feature if no matching feature
* was found
*/
QgsFeature getReferencedFeature( const QgsFeature &feature ) const;

Expand Down
2 changes: 1 addition & 1 deletion src/core/stac/qgsstacconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void QgsStacConnection::deleteConnection( const QString &name )
sTreeConnectionStac->deleteItem( name );
}

void QgsStacConnection::addConnection( const QString &name, QgsStacConnection::Data conn )
void QgsStacConnection::addConnection( const QString &name, const Data &conn )
{
settingsUrl->setValue( conn.url, name );
settingsAuthcfg->setValue( conn.authCfg, name );
Expand Down
2 changes: 1 addition & 1 deletion src/core/stac/qgsstacconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CORE_EXPORT QgsStacConnection : public QgsAbstractProviderConnection
//! Removes a connection from the list
static void deleteConnection( const QString &name );
//! Adds a new connection to the list
static void addConnection( const QString &name, Data conn );
static void addConnection( const QString &name, const Data &conn );
//! Returns last used connection
static QString selectedConnection();
//! Saves name of the last used connection
Expand Down
27 changes: 14 additions & 13 deletions src/gui/stac/qgsstacsourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void QgsStacSourceSelect::btnEdit_clicked()
nc.setConnection( cmbConnections->currentText(), uri );
if ( nc.exec() )
{
QgsStacConnection::Data connectionData = QgsStacConnection::decodedUri( nc.connectionUri() );
const QgsStacConnection::Data connectionData = QgsStacConnection::decodedUri( nc.connectionUri() );
QgsStacConnection::addConnection( nc.connectionName(), connectionData );
populateConnectionList();
emit connectionsChanged();
Expand Down Expand Up @@ -490,23 +490,24 @@ void QgsStacSourceSelect::showItemsContextMenu( QPoint point )
QMenu *menu = new QMenu( this );

QgsMessageBar *bar = nullptr;
QgsDataSourceManagerDialog *dsm = qobject_cast<QgsDataSourceManagerDialog *>( window() );
if ( dsm )
if ( QgsDataSourceManagerDialog *dsm = qobject_cast<QgsDataSourceManagerDialog *>( window() ) )
bar = dsm->messageBar();

const QgsStacItem *item = dynamic_cast<QgsStacItem *>( index.data( QgsStacItemListModel::Role::StacObject ).value<QgsStacObject *>() );
QMenu *assetsMenu = menu->addMenu( tr( "Add Layer" ) );
const QMap<QString, QgsStacAsset> assets = item->assets();
for ( const QgsStacAsset &asset : assets )
if ( const QgsStacItem *item = dynamic_cast<QgsStacItem *>( index.data( QgsStacItemListModel::Role::StacObject ).value<QgsStacObject *>() ) )
{
if ( asset.isCloudOptimized() )
const QMap<QString, QgsStacAsset> assets = item->assets();
for ( const QgsStacAsset &asset : assets )
{
QAction *loadAssetAction = new QAction( asset.title(), assetsMenu );
connect( loadAssetAction, &QAction::triggered, this, [this, &asset] {
QgsTemporaryCursorOverride cursorOverride( Qt::WaitCursor );
loadUri( asset.uri() );
} );
assetsMenu->addAction( loadAssetAction );
if ( asset.isCloudOptimized() )
{
QAction *loadAssetAction = new QAction( asset.title(), assetsMenu );
connect( loadAssetAction, &QAction::triggered, this, [this, uri = asset.uri()] {
QgsTemporaryCursorOverride cursorOverride( Qt::WaitCursor );
loadUri( uri );
} );
assetsMenu->addAction( loadAssetAction );
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/gui/vector/qgsattributesformproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ QgsAttributesFormProperties::RelationEditorConfiguration QgsAttributesFormProper
return mRelationEditorConfiguration;
}

void QgsAttributesFormProperties::DnDTreeItemData::setRelationEditorConfiguration( QgsAttributesFormProperties::RelationEditorConfiguration relationEditorConfiguration )
void QgsAttributesFormProperties::DnDTreeItemData::setRelationEditorConfiguration( const QgsAttributesFormProperties::RelationEditorConfiguration &relationEditorConfiguration )
{
mRelationEditorConfiguration = relationEditorConfiguration;
}
Expand All @@ -1904,7 +1904,7 @@ QgsAttributesFormProperties::QmlElementEditorConfiguration QgsAttributesFormProp
return mQmlElementEditorConfiguration;
}

void QgsAttributesFormProperties::DnDTreeItemData::setQmlElementEditorConfiguration( QgsAttributesFormProperties::QmlElementEditorConfiguration qmlElementEditorConfiguration )
void QgsAttributesFormProperties::DnDTreeItemData::setQmlElementEditorConfiguration( const QmlElementEditorConfiguration &qmlElementEditorConfiguration )
{
mQmlElementEditorConfiguration = qmlElementEditorConfiguration;
}
Expand All @@ -1915,7 +1915,7 @@ QgsAttributesFormProperties::HtmlElementEditorConfiguration QgsAttributesFormPro
return mHtmlElementEditorConfiguration;
}

void QgsAttributesFormProperties::DnDTreeItemData::setHtmlElementEditorConfiguration( QgsAttributesFormProperties::HtmlElementEditorConfiguration htmlElementEditorConfiguration )
void QgsAttributesFormProperties::DnDTreeItemData::setHtmlElementEditorConfiguration( const HtmlElementEditorConfiguration &htmlElementEditorConfiguration )
{
mHtmlElementEditorConfiguration = htmlElementEditorConfiguration;
}
Expand Down
39 changes: 36 additions & 3 deletions src/gui/vector/qgsattributesformproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,47 @@ class GUI_EXPORT QgsAttributesFormProperties : public QWidget, public QgsExpress
*/
void setCollapsedExpression( const QgsOptionalExpression &collapsedExpression );

/**
* Returns the relation editor configuration.
*
* \see setRelationEditorConfiguration()
*/
RelationEditorConfiguration relationEditorConfiguration() const;
void setRelationEditorConfiguration( RelationEditorConfiguration relationEditorConfiguration );

/**
* Sets the relation editor configuration.
*
* \see relationEditorConfiguration()
*/
void setRelationEditorConfiguration( const RelationEditorConfiguration &relationEditorConfiguration );

/**
* Returns the QML editor configuration.
*
* \see setQmlElementEditorConfiguration()
*/
QmlElementEditorConfiguration qmlElementEditorConfiguration() const;
void setQmlElementEditorConfiguration( QmlElementEditorConfiguration qmlElementEditorConfiguration );

/**
* Sets the QML editor configuration.
*
* \see qmlElementEditorConfiguration()
*/
void setQmlElementEditorConfiguration( const QmlElementEditorConfiguration &qmlElementEditorConfiguration );

/**
* Returns the HTML editor configuration.
*
* \see setHtmlElementEditorConfiguration()
*/
HtmlElementEditorConfiguration htmlElementEditorConfiguration() const;
void setHtmlElementEditorConfiguration( HtmlElementEditorConfiguration htmlElementEditorConfiguration );

/**
* Sets the HTML editor configuration.
*
* \see htmlElementEditorConfiguration()
*/
void setHtmlElementEditorConfiguration( const HtmlElementEditorConfiguration &htmlElementEditorConfiguration );

/**
* Returns the spacer element configuration
Expand Down

0 comments on commit 0baab44

Please sign in to comment.