Skip to content

Commit

Permalink
Avoid losing layer subset filters after fixing a layer path in the
Browse files Browse the repository at this point in the history
bad layers dialog

Filters are not automatically restored after fixing the path
  • Loading branch information
nyalldawson committed Aug 4, 2020
1 parent 27164f2 commit 826b703
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/qgshandlebadlayers.cpp
Expand Up @@ -425,8 +425,21 @@ void QgsHandleBadLayers::apply()
QgsMapLayer *mapLayer = QgsProject::instance()->mapLayer( layerId );
if ( mapLayer )
{
QString subsetString;
QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer *>( mapLayer );
if ( vlayer )
{
// store the previous layer subset string, so we can restore after fixing the data source
subsetString = vlayer->subsetString();
}

mapLayer->setDataSource( datasource, name, provider, options );
dataSourceChanged = mapLayer->isValid();

if ( dataSourceChanged && vlayer && !subsetString.isEmpty() )
{
vlayer->setSubsetString( subsetString );
}
}
}

Expand Down

0 comments on commit 826b703

Please sign in to comment.