Skip to content

Commit

Permalink
Fix geometry-less exported as empty layers
Browse files Browse the repository at this point in the history
If the selection by BBOX did not select anything, make sure we fool `QgsOfflineEditing` something is selected.
Otherwise when `layer.selectedFeatureIds().isEmpty()`, `QgsOfflineEditing` dumps all features.
NOTE that `layer.selectedFeatureIds()` should be renamed to `layer.requestedFeaturesIds()`, as it does
not indicate actual features ids being already selected.

This was wrongly applied on non-spatial layers, which caused them to be exported as empty layers.
  • Loading branch information
suricactus committed Feb 6, 2024
1 parent 8ee725c commit 4212f47
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libqfieldsync/offliners.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ def convert_to_offline(
else:
layer.selectByRect(bbox)

if layer.selectedFeatureCount() == 0:
layer.selectByIds([FID_NULL])
# If the selection by BBOX did not select anything, make sure we fool `QgsOfflineEditing` something is selected.
# Otherwise when `layer.selectedFeatureIds().isEmpty()`, `QgsOfflineEditing` dumps all features.
# NOTE that `layer.selectedFeatureIds()` should be renamed to `layer.requestedFeaturesIds()`, as it does
# not indicate actual features ids being already selected.
if layer.selectedFeatureCount() == 0:
layer.selectByIds([FID_NULL])

is_success = self.offliner.convertToOfflineProject(
str(offline_db_path),
Expand Down

0 comments on commit 4212f47

Please sign in to comment.