Skip to content

Commit 6299029

Browse files
committed
[composer] Ignore null field values or expressions which result in null
when evaluating data defined settings
1 parent 8725c2d commit 6299029

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/core/composer/qgscomposeritem.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect )
722722
bool ok;
723723
double width = exprVal.toDouble( &ok );
724724
QgsDebugMsg( QString( "exprVal Width:%1" ).arg( width ) );
725-
if ( ok )
725+
if ( ok && !exprVal.isNull() )
726726
{
727727
result.setWidth( width );
728728
}
@@ -732,7 +732,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect )
732732
bool ok;
733733
double height = exprVal.toDouble( &ok );
734734
QgsDebugMsg( QString( "exprVal Height:%1" ).arg( height ) );
735-
if ( ok )
735+
if ( ok && !exprVal.isNull() )
736736
{
737737
result.setHeight( height );
738738
}
@@ -753,7 +753,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect )
753753
bool ok;
754754
double positionX = exprVal.toDouble( &ok );
755755
QgsDebugMsg( QString( "exprVal Position X:%1" ).arg( positionX ) );
756-
if ( ok )
756+
if ( ok && !exprVal.isNull() )
757757
{
758758
x = positionX;
759759
}
@@ -775,7 +775,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect )
775775
bool ok;
776776
double positionY = exprVal.toDouble( &ok );
777777
QgsDebugMsg( QString( "exprVal Position Y:%1" ).arg( positionY ) );
778-
if ( ok )
778+
if ( ok && !exprVal.isNull() )
779779
{
780780
y = positionY;
781781
}
@@ -861,7 +861,7 @@ void QgsComposerItem::refreshBlendMode()
861861

862862
//data defined blend mode set?
863863
QVariant exprVal;
864-
if ( dataDefinedEvaluate( QgsComposerObject::BlendMode, exprVal ) )
864+
if ( dataDefinedEvaluate( QgsComposerObject::BlendMode, exprVal ) && !exprVal.isNull() )
865865
{
866866
QString blendstr = exprVal.toString().trimmed();
867867
QPainter::CompositionMode blendModeD = QgsSymbolLayerV2Utils::decodeBlendMode( blendstr );
@@ -891,7 +891,7 @@ void QgsComposerItem::refreshTransparency( const bool updateItem )
891891
bool ok;
892892
int transparencyD = exprVal.toInt( &ok );
893893
QgsDebugMsg( QString( "exprVal Transparency:%1" ).arg( transparencyD ) );
894-
if ( ok )
894+
if ( ok && !exprVal.isNull() )
895895
{
896896
transparency = transparencyD;
897897
}
@@ -1041,7 +1041,7 @@ void QgsComposerItem::refreshRotation( const bool updateItem , const bool adjust
10411041
bool ok;
10421042
double rotD = exprVal.toDouble( &ok );
10431043
QgsDebugMsg( QString( "exprVal Rotation:%1" ).arg( rotD ) );
1044-
if ( ok )
1044+
if ( ok && !exprVal.isNull() )
10451045
{
10461046
rotation = rotD;
10471047
}
@@ -1332,7 +1332,7 @@ void QgsComposerItem::refreshDataDefinedProperty( const QgsComposerObject::DataD
13321332
bool exclude = mExcludeFromExports;
13331333
//data defined exclude from exports set?
13341334
QVariant exprVal;
1335-
if ( dataDefinedEvaluate( QgsComposerObject::ExcludeFromExports, exprVal ) )
1335+
if ( dataDefinedEvaluate( QgsComposerObject::ExcludeFromExports, exprVal ) && !exprVal.isNull() )
13361336
{
13371337
exclude = exprVal.toBool();
13381338
}

src/core/composer/qgscomposermap.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ void QgsComposerMap::refreshMapExtents()
944944
bool ok;
945945
minXD = exprVal.toDouble( &ok );
946946
QgsDebugMsg( QString( "exprVal Map XMin:%1" ).arg( minXD ) );
947-
if ( ok )
947+
if ( ok && !exprVal.isNull() )
948948
{
949949
useDdXMin = true;
950950
newExtent.setXMinimum( minXD );
@@ -955,7 +955,7 @@ void QgsComposerMap::refreshMapExtents()
955955
bool ok;
956956
minYD = exprVal.toDouble( &ok );
957957
QgsDebugMsg( QString( "exprVal Map YMin:%1" ).arg( minYD ) );
958-
if ( ok )
958+
if ( ok && !exprVal.isNull() )
959959
{
960960
useDdYMin = true;
961961
newExtent.setYMinimum( minYD );
@@ -966,7 +966,7 @@ void QgsComposerMap::refreshMapExtents()
966966
bool ok;
967967
maxXD = exprVal.toDouble( &ok );
968968
QgsDebugMsg( QString( "exprVal Map XMax:%1" ).arg( maxXD ) );
969-
if ( ok )
969+
if ( ok && !exprVal.isNull() )
970970
{
971971
useDdXMax = true;
972972
newExtent.setXMaximum( maxXD );
@@ -977,7 +977,7 @@ void QgsComposerMap::refreshMapExtents()
977977
bool ok;
978978
maxYD = exprVal.toDouble( &ok );
979979
QgsDebugMsg( QString( "exprVal Map YMax:%1" ).arg( maxYD ) );
980-
if ( ok )
980+
if ( ok && !exprVal.isNull() )
981981
{
982982
useDdYMax = true;
983983
newExtent.setYMaximum( maxYD );
@@ -1021,7 +1021,7 @@ void QgsComposerMap::refreshMapExtents()
10211021
bool ok;
10221022
double scaleD = exprVal.toDouble( &ok );
10231023
QgsDebugMsg( QString( "exprVal Map Scale:%1" ).arg( scaleD ) );
1024-
if ( ok )
1024+
if ( ok && !exprVal.isNull() )
10251025
{
10261026
setNewScale( scaleD, false );
10271027
newExtent = *currentMapExtent();
@@ -1072,7 +1072,7 @@ void QgsComposerMap::refreshMapExtents()
10721072
bool ok;
10731073
double rotationD = exprVal.toDouble( &ok );
10741074
QgsDebugMsg( QString( "exprVal Map Rotation:%1" ).arg( rotationD ) );
1075-
if ( ok )
1075+
if ( ok && !exprVal.isNull() )
10761076
{
10771077
mapRotation = rotationD;
10781078
}
@@ -2331,7 +2331,7 @@ double QgsComposerMap::atlasMargin( const QgsComposerObject::PropertyValueType v
23312331
bool ok;
23322332
double ddMargin = exprVal.toDouble( &ok );
23332333
QgsDebugMsg( QString( "exprVal Map Atlas Margin:%1" ).arg( ddMargin ) );
2334-
if ( ok )
2334+
if ( ok && !exprVal.isNull() )
23352335
{
23362336
//divide by 100 to convert to 0 -> 1.0 range
23372337
margin = ddMargin / 100;

0 commit comments

Comments
 (0)