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

[Layer dependencies] Emit QgsVectorLayer::dataChanged on commitChanges #58528

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Djedouas
Copy link
Member

Description

Fixes #57784 where even if the layer is checked as a dependency layer, there is no reloading of data when the layer is saved.

With this change, the dataChanged signal is emitted on commitChanges, so that when a feature is externally modified on save (database trigger for example) we have index and cache reconstruction.


Related PRs:

This change is kind of following this particular comment/discussion #41463 (comment)

See the tests explaining the multiple emissions of dataChanged.

Ping @suricactus @m-kuhn @MorriganR @troopa81 @3nids for review

@github-actions github-actions bot added this to the 3.40.0 milestone Aug 29, 2024
@Djedouas Djedouas force-pushed the layer-dependency-on-commit-changes branch from c0c4bf6 to 9bf2d45 Compare August 29, 2024 18:38
Copy link

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 9bf2d45)

@troopa81
Copy link
Contributor

troopa81 commented Sep 2, 2024

@Djedouas After a second thought on our discussion I'm wondering if we could not fire only one dataChange on commit instead of 2 when adding (delete the -1 feature +add the inserted one) and 0 (3 with your proposal) when commit. Of course, without changing the general behavior when it's not about committing.

We could use the mCommitChangesActive boolean to have a different behavior in emitDataChanged() method. This behavior would not reset mDataChangedFired to false and it would be done when mCommitChangesActive is reset after commit ? Would that work?

@nyalldawson
Copy link
Collaborator

This is potentially a big speed regression -- eg QgsPointLocator connects to QgsVectorLayer::dataChanged and destroys the index when it's emitted, and the attribute table (via QgsVectorLayerCache) will also trigger a full rebuild. My understanding was that dataChanged should only be used when we don't know what's changed, but when we DO know what's changed the atomic signals (featureAdded, etc) are better because we can handle them in optimised ways.

Isn't all this supposed to be handled by the logic in QgsVectorLayer::setDependencies anyway? That's setting up manual connections to emit dataChanged when the atomic signals are received from a dependent layer.

@troopa81
Copy link
Contributor

troopa81 commented Sep 3, 2024

My understanding was that dataChanged should only be used when we don't know what's changed, but when we DO know what's changed the atomic signals (featureAdded, etc) are better because we can handle them in optimised ways.

That's the case here, a dependency has been committed, and so eventually the layer depending on it has also changed (because of trigger for instance) and need to fire dataChanged . This PR doesn't change this.

Isn't all this supposed to be handled by the logic in QgsVectorLayer::setDependencies anyway? That's setting up manual connections to emit dataChanged when the atomic signals are received from a dependent layer.

Yes, that's what it's intended here (don't know why we reloadData() and not just fire dataChanged signal in that case). I don't see any regression here, except IMHO we fire too many dataChanged per event.

@agiudiceandrea agiudiceandrea added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Sep 8, 2024
@nyalldawson nyalldawson added the Freeze Exempt Feature Freeze exemption granted label Sep 13, 2024
Copy link

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 28, 2024
@Djedouas Djedouas removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 30, 2024
Copy link

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Oct 15, 2024
@nyalldawson nyalldawson removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Oct 16, 2024
@nyalldawson
Copy link
Collaborator

I'm confused now -- was a force push used here to change the approach? The current changes don't seem to match with the PR description (or more recollections from previously reviewing this)

@Djedouas
Copy link
Member Author

Nothing changed since the PR creation

Now when a feature is externally modified on save (database trigger for
example), the dataChanged signal is emitted for indexes and caches
reconstruction.
Copy link

github-actions bot commented Nov 1, 2024

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Nov 1, 2024
@Djedouas Djedouas removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Nov 4, 2024
@Djedouas Djedouas force-pushed the layer-dependency-on-commit-changes branch from 9bf2d45 to 37e70f3 Compare November 5, 2024 15:38
Copy link

github-actions bot commented Nov 5, 2024

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 98a6c9a)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 98a6c9a)

@Djedouas Djedouas force-pushed the layer-dependency-on-commit-changes branch from 37e70f3 to 6061bcc Compare November 6, 2024 15:28
Copy link
Contributor

@troopa81 troopa81 left a comment

Choose a reason for hiding this comment

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

@nyalldawson @m-kuhn

We discussed this with @Djedouas , I think the proposal is good as it implies only one additional signal firing when committing instead of 3 (feature added+deleted+commit) when it comes to new feature.

@Djedouas Djedouas force-pushed the layer-dependency-on-commit-changes branch from 6061bcc to 98a6c9a Compare November 7, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Freeze Exempt Feature Freeze exemption granted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rubberband/snapping using old nodes if a geometry is modified outside QGIS
4 participants