Skip to content

Commit b45ab5d

Browse files
committedDec 4, 2018
Tell the bridge to update when a bad layer was fixed
This fixes an unreported issue: when a bad layer is fixed it does not appear in the layer order panel. The reason why it does not appear is that a bad layer has no geometry information, and the layer order model does not list geometryless layers. But after a bad layer has been fixed, it has a geometry and the panel should show it.
1 parent 930c56f commit b45ab5d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6976,21 +6976,21 @@ void QgisApp::changeDataSource( QgsMapLayer *layer )
69766976
QgsMimeDataUtils::Uri uri( dlg.uri() );
69776977
if ( uri.isValid() )
69786978
{
6979-
bool layerIsValid( layer->isValid() );
6979+
bool layerWasValid( layer->isValid() );
69806980
// Store subset string form vlayer if we are fixing a bad layer
69816981
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
69826982
QString subsetString;
69836983
// Get the subset string directly from the data provider because
69846984
// layer's method will return a null string from invalid layers
6985-
if ( !layerIsValid && vlayer && vlayer->dataProvider() &&
6985+
if ( !layerWasValid && vlayer && vlayer->dataProvider() &&
69866986
vlayer->dataProvider()->supportsSubsetString() &&
69876987
!vlayer->dataProvider()->subsetString( ).isEmpty() )
69886988
{
69896989
subsetString = vlayer->dataProvider()->subsetString();
69906990
}
69916991
layer->setDataSource( uri.uri, layer->name(), uri.providerKey, QgsDataProvider::ProviderOptions() );
69926992
// Re-apply original style and subset string when fixing bad layers
6993-
if ( !( layerIsValid || layer->originalXmlProperties().isEmpty() ) )
6993+
if ( !( layerWasValid || layer->originalXmlProperties().isEmpty() ) )
69946994
{
69956995
if ( ! subsetString.isEmpty() )
69966996
{
@@ -7030,6 +7030,12 @@ void QgisApp::changeDataSource( QgsMapLayer *layer )
70307030
tl->setItemVisibilityChecked( true );
70317031
}
70327032
}
7033+
7034+
// Tell the bridge that we have fixed a layer
7035+
if ( ! layerWasValid && layer->isValid() )
7036+
{
7037+
QgsProject::instance()->layerTreeRoot()->customLayerOrderChanged( );
7038+
}
70337039
}
70347040
}
70357041
}

0 commit comments

Comments
 (0)
Please sign in to comment.