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

[Backport release-3_18] Bugfix gh41477 editbuffer passthrough #41793

Closed
wants to merge 3 commits into from

Conversation

github-actions[bot]
Copy link

Backport b3dae9a from #41539

@elpaso elpaso added this to the 3.18.2 milestone Feb 24, 2021
@nyalldawson nyalldawson reopened this Feb 24, 2021
@nyalldawson nyalldawson added NOT FOR MERGE Don't merge! and removed NOT FOR MERGE Don't merge! labels Feb 27, 2021
@nyalldawson nyalldawson reopened this Feb 27, 2021
@nyalldawson nyalldawson added the Backport Is a backport of another pull request label Mar 1, 2021
@github-actions
Copy link
Author

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 Mar 16, 2021
@nyalldawson nyalldawson added the NOT FOR MERGE Don't merge! label Mar 18, 2021
@elpaso elpaso removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Mar 23, 2021
@@ -874,7 +874,7 @@ QgsRectangle QgsVectorLayer::extent() const
}

if ( !mEditBuffer ||
( mEditBuffer->mDeletedFeatureIds.isEmpty() && mEditBuffer->mChangedGeometries.isEmpty() ) ||
( !mDataProvider->transaction() && ( mEditBuffer->deletedFeatureIds().isEmpty() && mEditBuffer->changedGeometries().isEmpty() ) ) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be a bit cleaner if the !mDataProvider->transaction() checks were instead handled by either dynamic casting mEditBuffer to QgsVectorLayerEditPassthrough or by a new "isPassthrough" or "buffersChanges" method QgsVectorLayerEditBuffer which is overridden by QgsVectorLayerEditPassthrough. Then we'd have a cleaner separation between transactions and the use of QgsVectorLayerEditPassthrough (which may potentially be used in other situations in future, or by plugins...)

Copy link
Contributor

Choose a reason for hiding this comment

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

I've added isPassthrough() to edit buffer for a clearer semantic

QgsFeatureRequest request;
request.setFilterFid( mFid );
request.setSubsetOfAttributes( {} );
std::unique_ptr<QgsVectorLayer> layerClone( layer()->clone() );
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is very expensive to call. Why are we using a clone here instead of getting the features from the data provider directly?

Copy link
Contributor

Choose a reason for hiding this comment

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

We cannot use the provider directly because it will "see" what is in the current transaction and not the status of the backend storage. What we need here is to know if the geometry has changed from what is in the storage outside of the current transaction.

I can't think of another way to access the status of the storage outside of the transaction than cloning the provider but suggestions are welcome.

request.setFilterFid( mFid );
request.setFlags( QgsFeatureRequest::NoGeometry );
request.setSubsetOfAttributes( QgsAttributeList() << mFieldIndex );
std::unique_ptr<QgsVectorLayer> layerClone( layer()->clone() );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here -- this is very expensive to call. Is there no other approach?

@nyalldawson
Copy link
Collaborator

@elpaso reviewed!

@elpaso elpaso force-pushed the backport-41539-to-release-3_18 branch from 678aaa3 to b013991 Compare April 6, 2021 07:26
@elpaso
Copy link
Contributor

elpaso commented Apr 7, 2021

While working on this I discovered many more bugs that should be fixed, I'm closing this and I will continue to submit the patches on master. I will hopefully find the time to do another backport eventually.

@elpaso elpaso closed this Apr 7, 2021
@elpaso elpaso deleted the backport-41539-to-release-3_18 branch April 7, 2021 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport Is a backport of another pull request NOT FOR MERGE Don't merge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants