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

Restore original subsetString() when QgsVectorLayerProperties dialog is canceled (fix #13620) #2480

Closed
wants to merge 2 commits into from

Conversation

SebDieBln
Copy link
Contributor

This PR saves the original subsetString() of the layer and restores it when the user cancels the properties dialog. This is necessary because QgsQueryBuilder::accept() stores the new subset string directly in the layer thereby making it persistent even if the user cancels the QgsVectorLayerProperties dialog.

@m-kuhn
Copy link
Member

m-kuhn commented Nov 18, 2015

Wouldn't it be better to set it only on apply/ok instead of restoring on cancel?

@SebDieBln
Copy link
Contributor Author

I agree that's what one would expect. But there are some points to consider here:

  • QgsQueryBuilder is part of the API and might be used by third-party plugins expecting it to behave like before.
  • Filtering a layer impacts other functions in the properties dialog, e.g. the field calculators update existing field function, maybe more.
  • We already have the same situation with vectorJoins(). It is restored to its original value on cancel, because all changes have to be applied directly to the layer.

@m-kuhn
Copy link
Member

m-kuhn commented Nov 18, 2015

Valid points.

The first one could easily be solved by adding a new method on QgsQueryBuilder that disables auto-apply.

The second one is actually a problem with the fact that the field calculator is not really a layer property. So there is probably no "right" solution. The best would probably be to disable the field calculator if the query string has been changed and not applied or in raise a warning and propose to apply before opening the field calculator.

The third one (joins) could IMO be changed to the same workflow (copy fields, modify the copy, warn on certain functions as long as copy and original differ).

However, if you don't have the time to work on this, the current PR already improves the situation considerably.

@SebDieBln
Copy link
Contributor Author

OK, then I would leave this PR to be merged as it is and the workflow you suggested to be implemented later with a new PR.

@@ -531,6 +532,7 @@ void QgsVectorLayerProperties::apply()
layer->setSubsetString( txtSubsetSQL->toPlainText() );
mMetadataFilled = false;
}
mOriginalSubsetSQL = txtSubsetSQL->toPlainText();
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to set it to layer->subsetString() instead of this, it's possible that the providers trim whitespaces or similar magic.

@m-kuhn m-kuhn added the Requires Changes! Waiting on the submitter to make requested changes label Nov 18, 2015
@m-kuhn m-kuhn self-assigned this Nov 18, 2015
@m-kuhn m-kuhn added this to the 2.14 milestone Nov 18, 2015
@m-kuhn
Copy link
Member

m-kuhn commented Nov 18, 2015

Merged as 5399855
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Requires Changes! Waiting on the submitter to make requested changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants