Skip to content

Commit

Permalink
[composer] Ignore null field values or expressions which result in null
Browse files Browse the repository at this point in the history
when evaluating data defined settings
  • Loading branch information
nyalldawson committed Sep 29, 2014
1 parent 8725c2d commit 6299029
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/core/composer/qgscomposeritem.cpp
Expand Up @@ -722,7 +722,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect )
bool ok;
double width = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Width:%1" ).arg( width ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
result.setWidth( width );
}
Expand All @@ -732,7 +732,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect )
bool ok;
double height = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Height:%1" ).arg( height ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
result.setHeight( height );
}
Expand All @@ -753,7 +753,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect )
bool ok;
double positionX = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Position X:%1" ).arg( positionX ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
x = positionX;
}
Expand All @@ -775,7 +775,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect )
bool ok;
double positionY = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Position Y:%1" ).arg( positionY ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
y = positionY;
}
Expand Down Expand Up @@ -861,7 +861,7 @@ void QgsComposerItem::refreshBlendMode()

//data defined blend mode set?
QVariant exprVal;
if ( dataDefinedEvaluate( QgsComposerObject::BlendMode, exprVal ) )
if ( dataDefinedEvaluate( QgsComposerObject::BlendMode, exprVal ) && !exprVal.isNull() )
{
QString blendstr = exprVal.toString().trimmed();
QPainter::CompositionMode blendModeD = QgsSymbolLayerV2Utils::decodeBlendMode( blendstr );
Expand Down Expand Up @@ -891,7 +891,7 @@ void QgsComposerItem::refreshTransparency( const bool updateItem )
bool ok;
int transparencyD = exprVal.toInt( &ok );
QgsDebugMsg( QString( "exprVal Transparency:%1" ).arg( transparencyD ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
transparency = transparencyD;
}
Expand Down Expand Up @@ -1041,7 +1041,7 @@ void QgsComposerItem::refreshRotation( const bool updateItem , const bool adjust
bool ok;
double rotD = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Rotation:%1" ).arg( rotD ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
rotation = rotD;
}
Expand Down Expand Up @@ -1332,7 +1332,7 @@ void QgsComposerItem::refreshDataDefinedProperty( const QgsComposerObject::DataD
bool exclude = mExcludeFromExports;
//data defined exclude from exports set?
QVariant exprVal;
if ( dataDefinedEvaluate( QgsComposerObject::ExcludeFromExports, exprVal ) )
if ( dataDefinedEvaluate( QgsComposerObject::ExcludeFromExports, exprVal ) && !exprVal.isNull() )
{
exclude = exprVal.toBool();
}
Expand Down
14 changes: 7 additions & 7 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -944,7 +944,7 @@ void QgsComposerMap::refreshMapExtents()
bool ok;
minXD = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Map XMin:%1" ).arg( minXD ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
useDdXMin = true;
newExtent.setXMinimum( minXD );
Expand All @@ -955,7 +955,7 @@ void QgsComposerMap::refreshMapExtents()
bool ok;
minYD = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Map YMin:%1" ).arg( minYD ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
useDdYMin = true;
newExtent.setYMinimum( minYD );
Expand All @@ -966,7 +966,7 @@ void QgsComposerMap::refreshMapExtents()
bool ok;
maxXD = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Map XMax:%1" ).arg( maxXD ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
useDdXMax = true;
newExtent.setXMaximum( maxXD );
Expand All @@ -977,7 +977,7 @@ void QgsComposerMap::refreshMapExtents()
bool ok;
maxYD = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Map YMax:%1" ).arg( maxYD ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
useDdYMax = true;
newExtent.setYMaximum( maxYD );
Expand Down Expand Up @@ -1021,7 +1021,7 @@ void QgsComposerMap::refreshMapExtents()
bool ok;
double scaleD = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Map Scale:%1" ).arg( scaleD ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
setNewScale( scaleD, false );
newExtent = *currentMapExtent();
Expand Down Expand Up @@ -1072,7 +1072,7 @@ void QgsComposerMap::refreshMapExtents()
bool ok;
double rotationD = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Map Rotation:%1" ).arg( rotationD ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
mapRotation = rotationD;
}
Expand Down Expand Up @@ -2331,7 +2331,7 @@ double QgsComposerMap::atlasMargin( const QgsComposerObject::PropertyValueType v
bool ok;
double ddMargin = exprVal.toDouble( &ok );
QgsDebugMsg( QString( "exprVal Map Atlas Margin:%1" ).arg( ddMargin ) );
if ( ok )
if ( ok && !exprVal.isNull() )
{
//divide by 100 to convert to 0 -> 1.0 range
margin = ddMargin / 100;
Expand Down

0 comments on commit 6299029

Please sign in to comment.