Skip to content
Permalink
Browse files

Prevents a crash when online features are gone

Fixes an unreported segfault when converting an online layer
to offline if features cannot be (completely) fetched.

Funded by Boundless

(cherry-picked from 79442b6)
  • Loading branch information
elpaso authored and dakcarto committed Apr 22, 2016
1 parent 64f2903 commit 0c54862bdd9177ebbdebdd3f0c2b98a9489fc7ee
Showing with 11 additions and 2 deletions.
  1. +11 −2 src/core/qgsofflineediting.cpp
@@ -142,7 +142,7 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString& offlineDataPath,
layerIdMapping.insert( origLayerId, newLayer );
// remove remote layer
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << vl->id() );
QStringList() << origLayerId );
}
}

@@ -648,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" );

0 comments on commit 0c54862

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