mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
offline editing: add layer to map layer registry before
copying the symbology - otherwise edit widget settings won't be copied (fixes #11827)
This commit is contained in:
parent
2073c03931
commit
4938fe79e8
@ -233,13 +233,13 @@ void QgsOfflineEditing::synchronize()
|
||||
|
||||
QgsVectorLayer* offlineLayer = qobject_cast<QgsVectorLayer*>( layer );
|
||||
|
||||
// copy style
|
||||
copySymbology( offlineLayer, remoteLayer );
|
||||
|
||||
// register this layer with the central layers registry
|
||||
QgsMapLayerRegistry::instance()->addMapLayers(
|
||||
QList<QgsMapLayer *>() << remoteLayer, true );
|
||||
|
||||
// copy style
|
||||
copySymbology( offlineLayer, remoteLayer );
|
||||
|
||||
// apply layer edit log
|
||||
QString qgisLayerId = layer->id();
|
||||
QString sql = QString( "SELECT \"id\" FROM 'log_layer_ids' WHERE \"qgis_id\" = '%1'" ).arg( qgisLayerId );
|
||||
@ -557,6 +557,10 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
|
||||
newLayer->setCustomProperty( CUSTOM_PROPERTY_REMOTE_SOURCE, layer->source() );
|
||||
newLayer->setCustomProperty( CUSTOM_PROPERTY_REMOTE_PROVIDER, layer->providerType() );
|
||||
|
||||
// register this layer with the central layers registry
|
||||
QgsMapLayerRegistry::instance()->addMapLayers(
|
||||
QList<QgsMapLayer *>() << newLayer );
|
||||
|
||||
// copy style
|
||||
bool hasLabels = layer->hasLabelsEnabled();
|
||||
if ( !hasLabels )
|
||||
@ -565,10 +569,6 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
|
||||
copySymbology( layer, newLayer );
|
||||
}
|
||||
|
||||
// register this layer with the central layers registry
|
||||
QgsMapLayerRegistry::instance()->addMapLayers(
|
||||
QList<QgsMapLayer *>() << newLayer );
|
||||
|
||||
QgsLayerTreeGroup* layerTreeRoot = QgsProject::instance()->layerTreeRoot();
|
||||
// Find the parent group of the original layer
|
||||
QgsLayerTreeLayer* layerTreeLayer = layerTreeRoot->findLayer( layer->id() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user