Skip to content

Commit

Permalink
Some safety checks when working with geometryless layers
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/table_join_branch@14132 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Aug 23, 2010
1 parent e249f60 commit eafcb5a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/core/symbology-ng/qgssinglesymbolrendererv2.cpp
Expand Up @@ -59,6 +59,10 @@ QgsSymbolV2* QgsSingleSymbolRendererV2::symbolForFeature( QgsFeature& feature )

void QgsSingleSymbolRendererV2::startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer )
{
if ( !mSymbol )
{
return;
}
mRotationFieldIdx = ( mRotationField.isEmpty() ? -1 : vlayer->fieldNameIndex( mRotationField ) );
mSizeScaleFieldIdx = ( mSizeScaleField.isEmpty() ? -1 : vlayer->fieldNameIndex( mSizeScaleField ) );

Expand Down Expand Up @@ -93,6 +97,10 @@ void QgsSingleSymbolRendererV2::startRender( QgsRenderContext& context, const Qg

void QgsSingleSymbolRendererV2::stopRender( QgsRenderContext& context )
{
if ( !mSymbol )
{
return;
}
mSymbol->stopRender( context );

if ( mRotationFieldIdx != -1 || mSizeScaleFieldIdx != -1 )
Expand Down Expand Up @@ -127,7 +135,14 @@ void QgsSingleSymbolRendererV2::setSymbol( QgsSymbolV2* s )

QString QgsSingleSymbolRendererV2::dump()
{
return QString( "SINGLE: %1" ).arg( mSymbol->dump() );
if ( mSymbol )
{
return QString( "SINGLE: %1" ).arg( mSymbol->dump() );
}
else
{
return "";
}
}

QgsFeatureRendererV2* QgsSingleSymbolRendererV2::clone()
Expand Down Expand Up @@ -198,10 +213,12 @@ QDomElement QgsSingleSymbolRendererV2::save( QDomDocument& doc )

QgsLegendSymbologyList QgsSingleSymbolRendererV2::legendSymbologyItems( QSize iconSize )
{
QPixmap pix = QgsSymbolLayerV2Utils::symbolPreviewPixmap( mSymbol, iconSize );

QgsLegendSymbologyList lst;
lst << qMakePair( QString(), pix );
if ( mSymbol )
{
QPixmap pix = QgsSymbolLayerV2Utils::symbolPreviewPixmap( mSymbol, iconSize );
lst << qMakePair( QString(), pix );
}
return lst;
}

Expand Down

0 comments on commit eafcb5a

Please sign in to comment.