Skip to content

Commit

Permalink
offline editing: add layer to map layer registry before
Browse files Browse the repository at this point in the history
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 4938fe7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 )
Expand All @@ -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() );
Expand Down

0 comments on commit 4938fe7

Please sign in to comment.