Skip to content

Commit

Permalink
if layer has no selected features and "only selected features" option is
Browse files Browse the repository at this point in the history
set do not write all layer features (fix #50400)
  • Loading branch information
alexbruy authored and nyalldawson committed Jun 7, 2023
1 parent 1a6ef1c commit a7f78ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/analysis/processing/qgsalgorithmpackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ QVariantMap QgsPackageAlgorithm::processAlgorithm( const QVariantMap &parameters
case Qgis::LayerType::Vector:
{
QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( layer.get() );
const bool onlySaveSelected = vectorLayer->selectedFeatureCount() > 0 && selectedFeaturesOnly;
if ( !packageVectorLayer( vectorLayer, packagePath, context, &multiStepFeedback, saveStyles, saveMetadata, onlySaveSelected ) )
if ( !packageVectorLayer( vectorLayer, packagePath, context, &multiStepFeedback, saveStyles, saveMetadata, selectedFeaturesOnly ) )
errored = true;
else
outputLayers.append( QStringLiteral( "%1|layername=%2" ).arg( packagePath, layer->name() ) );
Expand Down
2 changes: 1 addition & 1 deletion tests/src/analysis/testqgsprocessingalgspt1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ void TestQgsProcessingAlgsPt1::packageAlg()
selectedPolygonsPackagedLayer = std::make_unique< QgsVectorLayer >( outputGpkg + "|layername=polygons", "polygons", "ogr" );
QVERIFY( selectedPolygonsPackagedLayer->isValid() );
QCOMPARE( selectedPolygonsPackagedLayer->wkbType(), mPolygonLayer->wkbType() );
QCOMPARE( selectedPolygonsPackagedLayer->featureCount(), 10 ); // With enabled SELECTED_FEATURES_ONLY all features should be saved when there is no selection
QCOMPARE( selectedPolygonsPackagedLayer->featureCount(), 0 ); // With enabled SELECTED_FEATURES_ONLY no features should be saved when there is no selection
}

void TestQgsProcessingAlgsPt1::rasterLayerProperties()
Expand Down

0 comments on commit a7f78ec

Please sign in to comment.