Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QgsVectorLayer: add addMultiRing and use it in QgsMapToolAddRing #50447

Merged
merged 9 commits into from
Oct 19, 2022

Conversation

lbartoletti
Copy link
Member

Description

The QgsMapToolAddRing adds a ring through the addRing method of QgsVectorLayerEditUtils called by this of QgsVectorLayer.

The bug described in #23113 indicates that only one of the entities receives the ring addition when using the map tool.

This is consistent with the documentation of the addRing methods. So, it is by design that the tool works like this.

However, as stated in the ticket, it is best to add the ring to all entities.

In order to avoid an api break, I added a new addMultiRing method that adds the ring on all entities.

Fixes #23113

recording_2022-10-03-161557.mp4

@github-actions github-actions bot added this to the 3.28.0 milestone Oct 3, 2022
@lbartoletti lbartoletti force-pushed the fix_23113_addring_all_layers_v2 branch from 3b8ff92 to 39ec98f Compare October 13, 2022 05:11
@lbartoletti lbartoletti added Bug Either a bug report, or a bug fix. Let's hope for the latter! backport queued_ltr_backports Queued Backports labels Oct 15, 2022
@lbartoletti lbartoletti force-pushed the fix_23113_addring_all_layers_v2 branch from 2aae8fd to bb0029c Compare October 17, 2022 08:41
Copy link
Collaborator

@nyalldawson nyalldawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got some unit tests coming too?

src/core/vector/qgsvectorlayereditutils.cpp Outdated Show resolved Hide resolved
src/core/vector/qgsvectorlayereditutils.h Outdated Show resolved Hide resolved
src/core/vector/qgsvectorlayereditutils.h Outdated Show resolved Hide resolved
The `QgsMapToolAddRing` adds a ring through the `addRing` method of
`QgsVectorLayerEditUtils` called by this of `QgsVectorLayer`.

The bug described in qgis#23113 indicates that only one of the entities receives the
ring addition when using the map tool.

This is consistent with the documentation of the `addRing` methods.
So, it is by design that the tool works like this.

However, as stated in the ticket, it is best to add the ring to all entities.

In order to avoid an api break, I added a new addMultiRing method that adds the ring on all entities.

Fixes qgis#23113
QgsMapToolAddRing can use the one from QgsVectorLayerEditUtils.
All checks are made inside QgsVectorLayerEditUtils.
Copy link
Contributor

@uclaros uclaros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like the addMultiRing() name, it kind of implies adding a MultiRing, if there is such a thing.
Imho, the old behavior is buggy and should be fixed on the existing methods. Is there a use case where the old only add a ring to a random intersecting polygon would be needed?

src/app/qgsmaptooladdring.cpp Outdated Show resolved Hide resolved
@uclaros uclaros disabled auto-merge October 18, 2022 09:33
@lbartoletti
Copy link
Member Author

I don't really like the addMultiRing() name, it kind of implies adding a MultiRing, if there is such a thing.

hmmm right, what's your suggestion?

Imho, the old behavior is buggy and should be fixed on the existing methods.

It was by design, and can't be fixed without an api break.

Is there a use case where the old only add a ring to a random intersecting polygon would be needed?

Personally, I don't know.

@uclaros
Copy link
Contributor

uclaros commented Oct 18, 2022

How about addRingV2()?

Also, a test case for "selected features only" would be nice

@lbartoletti
Copy link
Member Author

How about addRingV2()?

Also, a test case for "selected features only" would be nice

Done, thanks.

@lbartoletti lbartoletti force-pushed the fix_23113_addring_all_layers_v2 branch from 6e1ffc4 to 2cede13 Compare October 18, 2022 11:47
@lbartoletti lbartoletti merged commit 9a75180 into qgis:master Oct 19, 2022
@qgis-bot
Copy link
Collaborator

The backport to queued_ltr_backports failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply b09c2d1132... QgsVectorLayer: add addMultiRing and use it in QgsMapToolAddRing
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

stdout
Auto-merging python/core/auto_generated/vector/qgsvectorlayer.sip.in
Auto-merging src/app/qgsmaptooladdring.cpp
CONFLICT (content): Merge conflict in src/app/qgsmaptooladdring.cpp
Auto-merging src/core/vector/qgsvectorlayer.cpp
Auto-merging src/core/vector/qgsvectorlayer.h

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-queued_ltr_backports queued_ltr_backports
# Navigate to the new working tree
cd .worktrees/backport-queued_ltr_backports
# Create a new branch
git switch --create backport-50447-to-queued_ltr_backports
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick b09c2d113232ca1b4c5cc1e6be8cd5ad372f5019,6ebb15db9c937b73b46727fe98e31903ffd360a3,992e2bf1dfec13291f13b59a266dd54b41e5d05d,5d7a0253040243f85c5f6e17b6bf40dea758c69c,6a1222f187f68e250139cbf44add069ae4077cc4,cc07d1e7772e868779c76f947b6fccfadb6a198a,732be4999a00b927e0fd8deee4212724564add5b,e3bf816f55b4b52aeca0e3bcade04aac0dc5f132,2cede134edd84d69b86016eee97b2ca332af547d
# Push it to GitHub
git push --set-upstream origin backport-50447-to-queued_ltr_backports
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-queued_ltr_backports

Then, create a pull request where the base branch is queued_ltr_backports and the compare/head branch is backport-50447-to-queued_ltr_backports.

@qgis-bot qgis-bot added the failed backport The automated backport attempt failed, needs a manual backport label Oct 19, 2022
lbartoletti added a commit to lbartoletti/QGIS that referenced this pull request Oct 19, 2022
@nyalldawson
Copy link
Collaborator

@lbartoletti looks like this has introduced a flaky test -- see eg #50597

@lbartoletti lbartoletti deleted the fix_23113_addring_all_layers_v2 branch October 24, 2022 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport queued_ltr_backports Queued Backports Bug Either a bug report, or a bug fix. Let's hope for the latter! failed backport The automated backport attempt failed, needs a manual backport
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Digitizing: "Add Ring" tool doesn't consider all the overlapping features
4 participants