Skip to content
Permalink
Browse files

Minor style changes: same logic as before

  • Loading branch information
elpaso committed Mar 25, 2019
1 parent 8e42783 commit 7c8f58401cb56e2336674b469b3d0edebf10791f
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/app/qgshandlebadlayers.cpp
@@ -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();
@@ -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-- );
}
@@ -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;

0 comments on commit 7c8f584

Please sign in to comment.
You can’t perform that action at this time.