Skip to content

Commit

Permalink
Fix compiler warning in QgsMeshDatasetGroupStore::readXml()
Browse files Browse the repository at this point in the history
```
/home/even/qgis/qgis/src/core/mesh/qgsmeshdatasetgroupstore.cpp: In member function ‘void QgsMeshDatasetGroupStore::readXml(const QDomElement&, const QgsReadWriteContext&)’:
/home/even/qgis/qgis/src/core/mesh/qgsmeshdatasetgroupstore.cpp:329:29: warning: ‘sourceIndex’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  329 |     mRegistery[globalIndex] = DatasetGroup{source, sourceIndex};

```

Introduced in 7a1c29d, so master only
  • Loading branch information
rouault authored and nyalldawson committed May 20, 2021
1 parent f52f2b4 commit e04499a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/core/mesh/qgsmeshdatasetgroupstore.cpp
Expand Up @@ -305,15 +305,16 @@ void QgsMeshDatasetGroupStore::readXml( const QDomElement &storeElem, const QgsR
while ( !datasetElem.isNull() )
{
int globalIndex = datasetElem.attribute( QStringLiteral( "global-index" ) ).toInt();
int sourceIndex;
int sourceIndex = -1;
QgsMeshDatasetSourceInterface *source = nullptr;
if ( datasetElem.attribute( QStringLiteral( "source-type" ) ) == QLatin1String( "persitent-provider" ) )
const QString sourceType = datasetElem.attribute( QStringLiteral( "source-type" ) );
if ( sourceType == QLatin1String( "persitent-provider" ) )
{
source = mPersistentProvider;
sourceIndex = datasetElem.attribute( QStringLiteral( "source-index" ) ).toInt();
mPersistentExtraDatasetGroupIndexes.append( globalIndex );
}
else if ( datasetElem.attribute( QStringLiteral( "source-type" ) ) == QLatin1String( "virtual" ) )
else if ( sourceType == QLatin1String( "virtual" ) )
{
source = mExtraDatasets.get();
QString name = datasetElem.attribute( QStringLiteral( "name" ) );
Expand All @@ -325,8 +326,14 @@ void QgsMeshDatasetGroupStore::readXml( const QDomElement &storeElem, const QgsR
extraDatasetGroups[globalIndex] = dsg;
sourceIndex = mExtraDatasets->addDatasetGroup( dsg );
}

mRegistery[globalIndex] = DatasetGroup{source, sourceIndex};
else
{
QgsDebugMsg( QStringLiteral( "Unhandled source-type: %1." ).arg( sourceType ) );
}
if ( source )
{
mRegistery[globalIndex] = DatasetGroup{source, sourceIndex};
}

datasetElem = datasetElem.nextSiblingElement( QStringLiteral( "mesh-dataset" ) );
}
Expand Down

0 comments on commit e04499a

Please sign in to comment.