Skip to content

Commit

Permalink
Fix #10202 (fix crash in graduated symbol renderer)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jun 10, 2014
1 parent a19886d commit ff9356f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,15 @@ QList<QString> QgsCategorizedSymbolRendererV2::usedAttributes()
{
QSet<QString> attributes;

if ( QgsExpression* exp = QgsSymbolLayerV2Utils::fieldOrExpressionToExpression( mAttrName ) )
{
attributes.unite( exp->referencedColumns().toSet() );
delete exp;
}
// mAttrName can contain either attribute name or an expression.
// Sometimes it is not possible to distinguish between those two,
// e.g. "a - b" can be both a valid attribute name or expression.
// Since we do not have access to fields here, try both options.
attributes << mAttrName;

QgsExpression testExpr( mAttrName );
if ( !testExpr.hasParserError() )
attributes.unite( testExpr.referencedColumns().toSet() );

if ( mRotation.data() ) attributes.unite( mRotation->referencedColumns().toSet() );
if ( mSizeScale.data() ) attributes.unite( mSizeScale->referencedColumns().toSet() );
Expand Down
14 changes: 9 additions & 5 deletions src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,15 @@ QList<QString> QgsGraduatedSymbolRendererV2::usedAttributes()
{
QSet<QString> attributes;

if ( QgsExpression* exp = QgsSymbolLayerV2Utils::fieldOrExpressionToExpression( mAttrName ) )
{
attributes.unite( exp->referencedColumns().toSet() );
delete exp;
}
// mAttrName can contain either attribute name or an expression.
// Sometimes it is not possible to distinguish between those two,
// e.g. "a - b" can be both a valid attribute name or expression.
// Since we do not have access to fields here, try both options.
attributes << mAttrName;

QgsExpression testExpr( mAttrName );
if ( !testExpr.hasParserError() )
attributes.unite( testExpr.referencedColumns().toSet() );

if ( mRotation.data() ) attributes.unite( mRotation->referencedColumns().toSet() );
if ( mSizeScale.data() ) attributes.unite( mSizeScale->referencedColumns().toSet() );
Expand Down

0 comments on commit ff9356f

Please sign in to comment.