Skip to content

Commit

Permalink
Fix wrong cat renderer feature count for NULLs
Browse files Browse the repository at this point in the history
Fixes #45280
  • Loading branch information
elpaso authored and nyalldawson committed Nov 1, 2021
1 parent 935fb7c commit d9af4dd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/symbology/qgscategorizedsymbolrenderer.cpp
Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down

0 comments on commit d9af4dd

Please sign in to comment.