diff --git a/src/core/qgspallabeling.cpp b/src/core/qgspallabeling.cpp index 74f0479..146e3b8 100644 --- a/src/core/qgspallabeling.cpp +++ b/src/core/qgspallabeling.cpp @@ -462,6 +462,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context ) { QString labelText; + QVariant result; // Check to see if we are a expression string. if ( isExpression ) { @@ -471,19 +472,23 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f QgsDebugMsg( "Expression parser error:" + exp->parserErrorString() ); return; } - QVariant result = exp->evaluate( &f, layer->pendingFields() ); + result = exp->evaluate( &f, layer->pendingFields() ); if ( exp->hasEvalError() ) { QgsDebugMsg( "Expression parser eval error:" + exp->evalErrorString() ); return; } - labelText = result.toString(); + + } + else + { + result=f.attributeMap()[fieldIndex]; } - else if ( formatNumbers == true && ( f.attributeMap()[fieldIndex].type() == QVariant::Int || - f.attributeMap()[fieldIndex].type() == QVariant::Double ) ) + + if ( formatNumbers == true && ( result.type() == QVariant::Int || result.type() == QVariant::Double ) ) { QString numberFormat; - double d = f.attributeMap()[fieldIndex].toDouble(); + double d = result.toDouble(); if ( d > 0 && plusSign == true ) { numberFormat.append( "+" ); @@ -493,7 +498,7 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f } else { - labelText = f.attributeMap()[fieldIndex].toString(); + labelText = result.toString(); } double labelX, labelY; // will receive label size