Skip to content

Commit

Permalink
Fix it's impossible to change a rule based labeling "else" rule
Browse files Browse the repository at this point in the history
back to a normal rule

Port fixes from rule based renderer else handling to rule based
labeling
  • Loading branch information
nyalldawson committed Jun 14, 2021
1 parent fac0450 commit fbd4e26
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/core/labeling/qgsrulebasedlabeling.cpp
Expand Up @@ -62,8 +62,10 @@ QgsRuleBasedLabeling::Rule::Rule( QgsPalLayerSettings *settings, double scaleMin
, mFilterExp( filterExp )
, mDescription( description )
, mElseRule( elseRule )

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

initFilter();
}

Expand Down Expand Up @@ -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 );
}
}

Expand Down

0 comments on commit fbd4e26

Please sign in to comment.