[Qgis-developer] QgsRendererRangeV2.symbol() dumps QGIS

Nyall Dawson nyall.dawson at gmail.com
Mon Mar 14 05:25:13 PDT 2016


On 14 March 2016 at 23:08, Tom Chadwin <tom.chadwin at nnpa.org.uk> wrote:
> I'm not sure how, but that line is no longer crashing. However, I am now
> getting a crash on a subsequent line:
>
> wallColor = symbol.symbolLayer(1).subSymbol().color().name()
>
> What is interesting is that it crashes not immediately, but on the third
> feature it loops to in "for feat in feats". Simplified code snippet:
>
> for feat in feats:
>     classAttribute = renderer.classAttribute()
>     attrValue = feat.attribute(classAttribute)
>     ranges = renderer.ranges()
>     for range in ranges:
>         if (attrValue >= range.lowerValue() and attrValue <=
> range.upperValue()):
>             symbol = range.symbol()
>     wallColor = symbol.symbolLayer(1).subSymbol().color().name()
>
> What could cause that last line to crash for some features but not others?

I think symbol is probably getting deleted by the renderer. I'd try
making a copy of it, eg

symbol = QgsSymbolV2( range.symbol() )

Nyall


>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/QgsRendererRangeV2-symbol-dumps-QGIS-tp5255977p5256206.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the Qgis-developer mailing list