Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 57d4dbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -129,6 +129,9 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString& offlineDataPath,
if ( newLayer )
{
layerIdMapping.insert( origLayerId, newLayer );
// remove remote layer
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << origLayerId );
}
}

Expand Down Expand Up @@ -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" );
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -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 )
Expand Down

0 comments on commit 57d4dbf

Please sign in to comment.