@@ -449,13 +449,17 @@ QgsPalLayerSettings::QgsPalLayerSettings()
449
449
450
450
// temp stuff for when drawing label components (don't copy)
451
451
showingShadowRects = false ;
452
+
453
+ QSettings settings;
454
+ mNullValue = settings.value ( " qgis/nullValue" , " NULL" ).toString ();
452
455
}
453
456
454
457
QgsPalLayerSettings::QgsPalLayerSettings ( const QgsPalLayerSettings& s )
455
458
{
456
459
// copy only permanent stuff
457
460
458
461
enabled = s.enabled ;
462
+ mNullValue = s.mNullValue ;
459
463
460
464
// text style
461
465
fieldName = s.fieldName ;
@@ -1702,11 +1706,12 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
1702
1706
QgsDebugMsgLevel ( QString ( " Expression parser eval error:%1" ).arg ( exp->evalErrorString () ), 4 );
1703
1707
return ;
1704
1708
}
1705
- labelText = result.toString ();
1709
+ labelText = result.isNull () ? mNullValue : result. toString ();
1706
1710
}
1707
1711
else
1708
1712
{
1709
- labelText = f.attribute ( fieldIndex ).toString ();
1713
+ const QVariant &v = f.attribute ( fieldIndex );
1714
+ labelText = v.isNull () ? mNullValue : v.toString ();
1710
1715
}
1711
1716
1712
1717
// data defined format numbers?
@@ -1741,7 +1746,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
1741
1746
QgsDebugMsgLevel ( QString ( " exprVal NumPlusSign:%1" ).arg ( signPlus ? " true" : " false" ), 4 );
1742
1747
}
1743
1748
1744
- QVariant textV = QVariant ( labelText );
1749
+ QVariant textV ( labelText );
1745
1750
bool ok;
1746
1751
double d = textV.toDouble ( &ok );
1747
1752
if ( ok )
0 commit comments