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

[bugfix] Fixes identify action on deactivated rules for QgsRuleBasedRenderer #6679

Merged
merged 7 commits into from
Mar 30, 2018

Conversation

pblottiere
Copy link
Member

@pblottiere pblottiere commented Mar 26, 2018

Description

This PR fixes an issue raised by @lbartoletti during its work on #6657 (comment).

Actually, if a ELSE rule is defined and activated within the rule based renderer, then all others rules are valid even if they're deactivated. Then, an identify action can be done on invisible features.

A video is available, allowing to highlight the issue: https://github.com/lbartoletti/lbartoletti.github.io/tree/master/willRenderFeature.

A unit test has been added to test the underlying willRenderFeature method.

Checklist

  • Commit messages are descriptive and explain the rationale for changes
  • Commits which fix bugs include fixes #11111 in the commit message next to the description
  • Commits which add new features are tagged with [FEATURE] in the commit message
  • Commits which change the UI or existing user workflows are tagged with [needs-docs] in the commit message and containt sufficient information in the commit message to be documented
  • I have read the QGIS Coding Standards and this PR complies with them
  • This PR passes all existing unit tests (test results will be reported by travis-ci after opening this PR)
  • New unit tests have been added for core changes
  • I have run the scripts/prepare-commit.sh script before each commit

@pblottiere
Copy link
Member Author

@nyalldawson Can you give me your opinion on this PR if you have some time? Thanks :)

@DelazJ
Copy link
Contributor

DelazJ commented Mar 26, 2018

@pblottiere I'm not sure but how close is this issue to https://issues.qgis.org/issues/18143?

@lbartoletti
Copy link
Member

@pblottiere Tested and it's ok for me. Thanks!

This is not yours, but for other reviewers, a comment on QgsNullSymbolRenderer should be always false IMHO.

@DelazJ 👍

@pblottiere
Copy link
Member Author

@Gustry

Hi Etienne,

I think this PR fixes an issue you raised some time ago : https://issues.qgis.org/issues/13999

Before:

feature_count_bug

Now:

feature_count_fixed

@pblottiere
Copy link
Member Author

@DelazJ

I'm not sure but how close is this issue to https://issues.qgis.org/issues/18143?

Mmm I'm not sure either. But this issue leads me to another one : https://issues.qgis.org/issues/13999

Thank you for that!

@DelazJ
Copy link
Contributor

DelazJ commented Mar 27, 2018

But this issue leads me to another one : https://issues.qgis.org/issues/13999

Yes, also saw it when looking for the report. Wanted to point you to it but as it was mentioned in the first link, i just crossed my fingers and hoped you tackle both of them ;). Good it's gone; this was an annoying issue when willing to show feature count in legend. Thanks Paul.

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.

Looks great!

(You didn't happen to see any possible reason for the long-standing random crashes that the rule based renderer test experiences did you? That one has me totally stumped.)

@@ -343,7 +343,7 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer
QSet< QString > legendKeysForFeature( QgsFeature &feat, QgsRenderContext *context = nullptr );

//! tell which rules will be used to render the feature
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add an explanation of the onlyActive argument here too

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@nyalldawson
Copy link
Collaborator

@lbartoletti

This is not yours, but for other reviewers, a comment on QgsNullSymbolRenderer should be always false IMHO.

Can we discuss that elsewhere? I personally think it's nice to be able to see selected features even with the null renderer.

@pblottiere
Copy link
Member Author

Travis is green, I'll merge this PR tomorrow if I have no more comments in the meantime.

@pblottiere pblottiere merged commit 4be8baa into qgis:master Mar 30, 2018
@nyalldawson
Copy link
Collaborator

Great work @pblottiere!

@m-kuhn
Copy link
Member

m-kuhn commented Apr 17, 2018

This causes a regression, I guess related to nested ELSE rules.

image

In such a scenario, the identify action will not discover visible features which are rendered by one of the nested rules within the ELSE.

rendered = renderer.willRenderFeature(ft, ctx)
renderer.stopRender(ctx)
renderer.rootRule().children()[0].setActive(True)
assert rendered == False
Copy link
Member

Choose a reason for hiding this comment

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

As a general input, better use the self.assertFalse() etc methods, they give a much better output if they fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants