Skip to content

Commit abf2398

Browse files
committedAug 15, 2015
Rule based renderer: empty rule matches all
Fix #13218
1 parent 67a7d13 commit abf2398

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed
 

‎src/core/qgsvectorlayerrenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ bool QgsVectorLayerRenderer::render()
145145
.setFilterRect( requestExtent )
146146
.setSubsetOfAttributes( mAttrNames, mFields );
147147

148-
if ( !rendererFilter.isNull() )
148+
if ( !rendererFilter.isEmpty() )
149149
{
150150
featureRequest.setFilterExpression( rendererFilter );
151151
}

‎src/core/symbology-ng/qgsrulebasedrendererv2.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,24 +427,33 @@ bool QgsRuleBasedRendererV2::Rule::startRender( QgsRenderContext& context, const
427427
}
428428
}
429429

430-
// subfilters (on the same level) are joined with OR and finally joined with AND with their parent (this) filter
430+
// subfilters (on the same level) are joined with OR
431+
// Finally they are joined with their parent (this) with AND
431432
QString sf;
432-
if ( subfilters.length() )
433+
// If there are subfilters present (and it's not a single empty one), group them and join them with OR
434+
if ( subfilters.length() > 1 || subfilters.value( 0 ).trimmed().length() > 0 )
433435
sf = subfilters.join( ") OR (" ).prepend( "(" ).append( ")" );
434436

437+
// Now join the subfilters with their parent (this) based on if
438+
// * The parent is an else rule
439+
// * The existence of parent filter and subfilters
440+
435441
if ( isElse() )
436442
{
437-
if ( !sf.length() )
443+
if ( !sf.trimmed().length() )
438444
filter = "TRUE";
439445
else
440446
filter = sf;
441447
}
442-
else if ( mFilterExp.length() && sf.length() )
448+
else if ( mFilterExp.trimmed().length() && sf.trimmed().length() )
443449
filter = QString( "(%1) AND (%2)" ).arg( mFilterExp ).arg( sf );
444-
else if ( mFilterExp.length() )
450+
else if ( mFilterExp.trimmed().length() )
445451
filter = mFilterExp;
446452
else
447453
filter = sf;
454+
455+
filter = filter.trimmed();
456+
448457
return true;
449458
}
450459

0 commit comments

Comments
 (0)
Please sign in to comment.