Skip to content

Commit eafcb5a

Browse files
author
mhugent
committed
Some safety checks when working with geometryless layers
git-svn-id: http://svn.osgeo.org/qgis/branches/table_join_branch@14132 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e249f60 commit eafcb5a

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/core/symbology-ng/qgssinglesymbolrendererv2.cpp

+21-4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ QgsSymbolV2* QgsSingleSymbolRendererV2::symbolForFeature( QgsFeature& feature )
5959

6060
void QgsSingleSymbolRendererV2::startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer )
6161
{
62+
if ( !mSymbol )
63+
{
64+
return;
65+
}
6266
mRotationFieldIdx = ( mRotationField.isEmpty() ? -1 : vlayer->fieldNameIndex( mRotationField ) );
6367
mSizeScaleFieldIdx = ( mSizeScaleField.isEmpty() ? -1 : vlayer->fieldNameIndex( mSizeScaleField ) );
6468

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

9498
void QgsSingleSymbolRendererV2::stopRender( QgsRenderContext& context )
9599
{
100+
if ( !mSymbol )
101+
{
102+
return;
103+
}
96104
mSymbol->stopRender( context );
97105

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

128136
QString QgsSingleSymbolRendererV2::dump()
129137
{
130-
return QString( "SINGLE: %1" ).arg( mSymbol->dump() );
138+
if ( mSymbol )
139+
{
140+
return QString( "SINGLE: %1" ).arg( mSymbol->dump() );
141+
}
142+
else
143+
{
144+
return "";
145+
}
131146
}
132147

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

199214
QgsLegendSymbologyList QgsSingleSymbolRendererV2::legendSymbologyItems( QSize iconSize )
200215
{
201-
QPixmap pix = QgsSymbolLayerV2Utils::symbolPreviewPixmap( mSymbol, iconSize );
202-
203216
QgsLegendSymbologyList lst;
204-
lst << qMakePair( QString(), pix );
217+
if ( mSymbol )
218+
{
219+
QPixmap pix = QgsSymbolLayerV2Utils::symbolPreviewPixmap( mSymbol, iconSize );
220+
lst << qMakePair( QString(), pix );
221+
}
205222
return lst;
206223
}
207224

0 commit comments

Comments
 (0)