Skip to content

Commit

Permalink
Minor style changes: same logic as before
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Mar 25, 2019
1 parent 8e42783 commit 7c8f584
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/app/qgshandlebadlayers.cpp
Expand Up @@ -366,7 +366,6 @@ void QgsHandleBadLayers::apply()
QHash<QString, QString> baseChange;



for ( int i = 0; i < mLayerList->rowCount(); i++ )
{
int idx = mLayerList->item( i, 0 )->data( Qt::UserRole ).toInt();
Expand Down Expand Up @@ -405,27 +404,27 @@ void QgsHandleBadLayers::apply()
datasource = datasource.replace( basepath, baseChange[basepath] );


bool dataSourceChanged { false };
bool dataSourceFixed { false };
const QString layerId { node.namedItem( QStringLiteral( "id" ) ).toElement().text() };
const QString provider { node.namedItem( QStringLiteral( "provider" ) ).toElement().text() };

// Try first to change the datasource of the existing layers, this will
// maintain the current status (checked/unchecked) and group
if ( QgsProject::instance()->mapLayer( layerId ) )
{
QgsDataProvider::ProviderOptions options;
QgsMapLayer *mapLayer = QgsProject::instance()->mapLayer( layerId );
if ( mapLayer )
{
QgsDataProvider::ProviderOptions options;
mapLayer->setDataSource( datasource, name, provider, options );
dataSourceChanged = mapLayer->isValid();
dataSourceFixed = mapLayer->isValid();
}
}

// If the data source was changed successfully, remove the bad layer from the dialog
// otherwise, try to set the new datasource in the XML node and reload the layer,
// finally marks with red all remaining bad layers.
if ( dataSourceChanged )
if ( dataSourceFixed )
{
mLayerList->removeRow( i-- );
}
Expand All @@ -447,7 +446,8 @@ void QgsHandleBadLayers::apply()
}
}

// Final cleanup: remove any bad layer (it should not be any btw)
// Final cleanup: remove any remaining bad layer
// (there should not be any at this point)
if ( mLayerList->rowCount() == 0 )
{
QList<QgsMapLayer *> toRemove;
Expand Down

0 comments on commit 7c8f584

Please sign in to comment.