Skip to content
Permalink
Browse files
Fix wrong cat renderer feature count for NULLs
Fixes #45280
  • Loading branch information
elpaso authored and nyalldawson committed Nov 1, 2021
1 parent 935fb7c commit d9af4dde14de18804d5f9d7f2e802cf5e66fcfdf
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/core/symbology/qgscategorizedsymbolrenderer.cpp
@@ -914,7 +914,7 @@ QgsLegendSymbolList QgsCategorizedSymbolRenderer::legendSymbolItems() const

QSet<QString> QgsCategorizedSymbolRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
{
QString value = valueForFeature( feature, context ).toString();
const QVariant value = valueForFeature( feature, context );
int i = 0;

for ( const QgsRendererCategory &cat : mCategories )
@@ -934,7 +934,17 @@ QSet<QString> QgsCategorizedSymbolRenderer::legendKeysForFeature( const QgsFeatu
}
else
{
match = value == cat.value();
// Numeric NULL cat value is stored as an empty string
if ( value.isNull() && ( value.type() == QVariant::Double || value.type() == QVariant::Int ||
value.type() == QVariant::UInt || value.type() == QVariant::LongLong ||
value.type() == QVariant::ULongLong ) )
{
match = cat.value().toString().isEmpty();
}
else
{
match = value == cat.value();
}
}

if ( match )

0 comments on commit d9af4dd

Please sign in to comment.