Skip to content

Commit

Permalink
prevent crash on multiple else rules (#51834)
Browse files Browse the repository at this point in the history
  • Loading branch information
roya0045 committed Feb 23, 2023
1 parent 603ccb2 commit 51e41d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/symbology/qgsrulebasedrenderer.cpp
Expand Up @@ -1159,7 +1159,7 @@ QString QgsRuleBasedRenderer::legendKeyToExpression( const QString &key, QgsVect
const QList<QgsRuleBasedRenderer::Rule *> siblings = rule->parent()->children();
for ( Rule *sibling : siblings )
{
if ( sibling == rule )
if ( sibling == rule || sibling->isElse() )
continue;

const QString siblingExpression = ruleToExpression( sibling );
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsrulebasedrenderer.cpp
Expand Up @@ -1279,12 +1279,14 @@ class TestQgsRuleBasedRenderer: public QgsTest
QgsRuleBasedRenderer::Rule *rule1 = new QgsRuleBasedRenderer::Rule( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ), 0, 0, "\"field_name\" = 1" );
QgsRuleBasedRenderer::Rule *rule2 = new QgsRuleBasedRenderer::Rule( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ), 0, 0, "\"field_name\" = 6" );
QgsRuleBasedRenderer::Rule *ruleElse = new QgsRuleBasedRenderer::Rule( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ), 0, 0, "ELSE" );
QgsRuleBasedRenderer::Rule *ruleElse2 = new QgsRuleBasedRenderer::Rule( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ), 0, 0, "ELSE" );

Q_ASSERT( ruleElse->isElse() );

rootRule->appendChild( rule1 );
rootRule->appendChild( rule2 );
rootRule->appendChild( ruleElse );
rootRule->appendChild( ruleElse2 );

bool ok;

Expand Down

0 comments on commit 51e41d2

Please sign in to comment.