Skip to content
Permalink
Browse files

Merge pull request #8607 from elpaso/handle-bad-layers-refresh-layer-…

…order

Tells the bridge to update when a bad layer was fixed
  • Loading branch information
elpaso committed Dec 5, 2018
2 parents 6044298 + b45ab5d commit a8be1ff37ca47be618576cc3390e4ad762ff99ff
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/app/qgisapp.cpp
@@ -6976,21 +6976,21 @@ void QgisApp::changeDataSource( QgsMapLayer *layer )
QgsMimeDataUtils::Uri uri( dlg.uri() );
if ( uri.isValid() )
{
bool layerIsValid( layer->isValid() );
bool layerWasValid( layer->isValid() );
// Store subset string form vlayer if we are fixing a bad layer
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
QString subsetString;
// Get the subset string directly from the data provider because
// layer's method will return a null string from invalid layers
if ( !layerIsValid && vlayer && vlayer->dataProvider() &&
if ( !layerWasValid && vlayer && vlayer->dataProvider() &&
vlayer->dataProvider()->supportsSubsetString() &&
!vlayer->dataProvider()->subsetString( ).isEmpty() )
{
subsetString = vlayer->dataProvider()->subsetString();
}
layer->setDataSource( uri.uri, layer->name(), uri.providerKey, QgsDataProvider::ProviderOptions() );
// Re-apply original style and subset string when fixing bad layers
if ( !( layerIsValid || layer->originalXmlProperties().isEmpty() ) )
if ( !( layerWasValid || layer->originalXmlProperties().isEmpty() ) )
{
if ( ! subsetString.isEmpty() )
{
@@ -7030,6 +7030,12 @@ void QgisApp::changeDataSource( QgsMapLayer *layer )
tl->setItemVisibilityChecked( true );
}
}

// Tell the bridge that we have fixed a layer
if ( ! layerWasValid && layer->isValid() )
{
QgsProject::instance()->layerTreeRoot()->customLayerOrderChanged( );
}
}
}
}

0 comments on commit a8be1ff

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