Skip to content
Permalink
Browse files
Fix it's impossible to change a rule based labeling "else" rule
back to a normal rule

Port fixes from rule based renderer else handling to rule based
labeling
  • Loading branch information
nyalldawson committed Jun 9, 2021
1 parent 7b884fb commit 880c358f31fa957b0c9741991f6e0d93916bf1c2
Showing with 10 additions and 6 deletions.
  1. +10 −6 src/core/labeling/qgsrulebasedlabeling.cpp
@@ -62,8 +62,10 @@ QgsRuleBasedLabeling::Rule::Rule( QgsPalLayerSettings *settings, double scaleMin
, mFilterExp( filterExp )
, mDescription( description )
, mElseRule( elseRule )

{
if ( mElseRule )
mFilterExp = QStringLiteral( "ELSE" );

initFilter();
}

@@ -94,18 +96,20 @@ QgsRuleBasedLabeling::RuleList QgsRuleBasedLabeling::Rule::descendants() const

void QgsRuleBasedLabeling::Rule::initFilter()
{
if ( mElseRule || mFilterExp.compare( QLatin1String( "ELSE" ), Qt::CaseInsensitive ) == 0 )
if ( mFilterExp.trimmed().compare( QLatin1String( "ELSE" ), Qt::CaseInsensitive ) == 0 )
{
mElseRule = true;
mFilter.reset( nullptr );
mFilter.reset( );
}
else if ( !mFilterExp.isEmpty() )
else if ( mFilterExp.trimmed().isEmpty() )
{
mFilter.reset( new QgsExpression( mFilterExp ) );
mElseRule = false;
mFilter.reset();
}
else
{
mFilter.reset( nullptr );
mElseRule = false;
mFilter = std::make_unique< QgsExpression >( mFilterExp );
}
}

0 comments on commit 880c358

Please sign in to comment.