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 Oct 4, 2021
1 parent 33c7323 commit 924eb4f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/symbology/qgscategorizedsymbolrenderer.cpp
Expand Up @@ -907,7 +907,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 @@ -927,7 +927,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 924eb4f

Please sign in to comment.