Bug report #16086

Feature count for {rule-based,categorized,graduated} renderer wrong when using joined fields upon project load

Added by Mathieu Pellerin - nIRV almost 8 years ago. Updated over 5 years ago.

Status:Feedback
Priority:Normal
Assignee:-
Category:Map Legend
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:24000

Description

When [x] show feature count is active on a {rule-based,categorized,graduated} renderer layer relying on a joined layer field, the layer's children counts (including composer legend items) will return 0 upon project load, and will stick to that wrong count unless a category is added/deleted.

Educated guess: upon project load, the feature count takes place prior to joining layer(s), resulting in the wrong 0 count.

Steps to reproduce
  1. Launch QGIS and open the attached test project (count.qgs)
  2. Notice the layer count on the layer panel is wrong (says 0 when you'll clearly see styled polygons on the map)
  3. Open the style dock, and add a category to the categorized renderer (i.e. push the [+] button)
  4. Notice the feature counts are now correct

count.zip (12.5 KB) Mathieu Pellerin - nIRV, 2017-01-16 07:21 PM

History

#1 Updated by Mathieu Pellerin - nIRV almost 8 years ago

  • Subject changed from layer count for {rule-based,categorized,graduated} renderer wrong when using joined fields upon project load to Feature count for {rule-based,categorized,graduated} renderer wrong when using joined fields upon project load

#2 Updated by Mathieu Pellerin - nIRV almost 8 years ago

I've looked into this by adding a couple of debug msgs. So basically what happens here is:
- layer A loaded
- layer A creates a join with layer B (however the data source for layer B isn't loaded)
- layer A's creation process calls createLayerTreeModelLegendNodes, within which mLayer->countSymbolFeatures(); is called, triggering a feature count
- layer A populates rule-based categories feature counts (triggered above), which will return 0 as the rule relies on values from layer B
- layer B loaded

#3 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No
  • Regression? set to No

#4 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

Please check if this issue is still valid on QGIS 3.4.5 or 3.6.

Also available in: Atom PDF