Skip to content
Permalink
Browse files

offline editing: add layer to map layer registry before

copying the symbology - otherwise edit widget settings
won't be copied (fixes #11827)
  • Loading branch information
jef-n committed Feb 10, 2015
1 parent 2073c03 commit 4938fe79e8a3fa5d7c03a40ba624c49712ad74bd
Showing with 7 additions and 7 deletions.
  1. +7 −7 src/core/qgsofflineediting.cpp
@@ -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() );

0 comments on commit 4938fe7

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