Skip to content
Permalink
Browse files

Merge pull request #3015 from boundlessgeo/wfs-getfeatures-offline-crash

Wfs getfeatures offline crash
  • Loading branch information
elpaso committed Apr 19, 2016
2 parents 8f0f9cc + 79442b6 commit 57d4dbf2ee6654292f1c9123a5cc0a0306e8d714
Showing with 14 additions and 6 deletions.
  1. +13 −5 src/core/qgsofflineediting.cpp
  2. +1 −1 src/providers/wfs/qgswfsprovider.cpp
@@ -129,6 +129,9 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString& offlineDataPath,
if ( newLayer )
{
layerIdMapping.insert( origLayerId, newLayer );
// remove remote layer
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << origLayerId );
}
}

@@ -645,7 +648,16 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
int remoteCount = remoteFeatureIds.size();
for ( int i = 0; i < remoteCount; i++ )
{
addFidLookup( db, layerId, offlineFeatureIds.at( i ), remoteFeatureIds.at( remoteCount - ( i + 1 ) ) );
// Check if the online feature has been fetched (WFS download aborted for some reason)
if ( i < offlineFeatureIds.count() )
{
addFidLookup( db, layerId, offlineFeatureIds.at( i ), remoteFeatureIds.at( remoteCount - ( i + 1 ) ) );
}
else
{
showWarning( QString( "Feature cannot be copied to the offline layer, please check if the online layer '%1' is sill accessible." ).arg( layer->name() ) );
return nullptr;
}
emit progressUpdated( featureCount++ );
}
sqlExec( db, "COMMIT" );
@@ -654,10 +666,6 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
{
showWarning( newLayer->commitErrors().join( "\n" ) );
}

// remove remote layer
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << layer->id() );
}
return newLayer;
}
@@ -189,7 +189,7 @@ bool QgsWFSProvider::isValid()

QgsFeatureIterator QgsWFSProvider::getFeatures( const QgsFeatureRequest& request )
{
return new QgsWFSFeatureIterator( new QgsWFSFeatureSource( this ), true, request );
return QgsFeatureIterator( new QgsWFSFeatureIterator( new QgsWFSFeatureSource( this ), true, request ) );
}

bool QgsWFSProvider::addFeatures( QgsFeatureList &flist )

0 comments on commit 57d4dbf

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