@@ -6976,21 +6976,21 @@ void QgisApp::changeDataSource( QgsMapLayer *layer )
6976
6976
QgsMimeDataUtils::Uri uri( dlg.uri() );
6977
6977
if ( uri.isValid() )
6978
6978
{
6979
- bool layerIsValid ( layer->isValid() );
6979
+ bool layerWasValid ( layer->isValid() );
6980
6980
// Store subset string form vlayer if we are fixing a bad layer
6981
6981
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
6982
6982
QString subsetString;
6983
6983
// Get the subset string directly from the data provider because
6984
6984
// layer's method will return a null string from invalid layers
6985
- if ( !layerIsValid && vlayer && vlayer->dataProvider() &&
6985
+ if ( !layerWasValid && vlayer && vlayer->dataProvider() &&
6986
6986
vlayer->dataProvider()->supportsSubsetString() &&
6987
6987
!vlayer->dataProvider()->subsetString( ).isEmpty() )
6988
6988
{
6989
6989
subsetString = vlayer->dataProvider()->subsetString();
6990
6990
}
6991
6991
layer->setDataSource( uri.uri, layer->name(), uri.providerKey, QgsDataProvider::ProviderOptions() );
6992
6992
// Re-apply original style and subset string when fixing bad layers
6993
- if ( !( layerIsValid || layer->originalXmlProperties().isEmpty() ) )
6993
+ if ( !( layerWasValid || layer->originalXmlProperties().isEmpty() ) )
6994
6994
{
6995
6995
if ( ! subsetString.isEmpty() )
6996
6996
{
@@ -7030,6 +7030,12 @@ void QgisApp::changeDataSource( QgsMapLayer *layer )
7030
7030
tl->setItemVisibilityChecked( true );
7031
7031
}
7032
7032
}
7033
+
7034
+ // Tell the bridge that we have fixed a layer
7035
+ if ( ! layerWasValid && layer->isValid() )
7036
+ {
7037
+ QgsProject::instance()->layerTreeRoot()->customLayerOrderChanged( );
7038
+ }
7033
7039
}
7034
7040
}
7035
7041
}
0 commit comments