[Qgis-developer] Crash when using new raster api from python

Tim Sutton lists at linfiniti.com
Wed Sep 12 14:18:02 PDT 2012


Hi

On Wed, Sep 12, 2012 at 5:12 PM, Tim Sutton <lists at linfiniti.com> wrote:
> Hi
>
> Has anyone else been testing the new raster API python bindings? If I
> load the tenbytenraster.asc in qgis (from unittest data) and then run
> the code below (by pasting into the qgis python console, I get a
> crash.  Seems like the culprit could be
> QgsRasterShader::~QgsRasterShader() but its not obvious to me why.

Ok fixed in master with 94c2e1c and regression test added to python
qgsrasterlayer test.

Regards

Tim

>
> Regards
>
> Tim
>
> from PyQt4 import QtGui
> from qgis.utils import iface as q
> r = q.activeLayer()
> s = QgsRasterShader()
> c = QgsColorRampShader()
> c.setColorRampType(QgsColorRampShader.INTERPOLATED)
> i = []
> item = QgsColorRampShader.ColorRampItem(10, QtGui.QColor('#ffff00'), 'foo')
> i.append(item)
> item = QgsColorRampShader.ColorRampItem(100, QtGui.QColor('#ff00ff'), 'bar')
> i.append(item)
> item = QgsColorRampShader.ColorRampItem(1000, QtGui.QColor('#00ff00'), 'kazam')
> i.append(item)
> c.setColorRampItemList(i)
> s.setRasterShaderFunction(c)
> ps = QgsSingleBandPseudoColorRenderer(r.dataProvider(), 1,  s)
> r.setRenderer(ps)
>
> ######## works first time #############
>
> s = QgsRasterShader()
> c = QgsColorRampShader()
> c.setColorRampType(QgsColorRampShader.INTERPOLATED)
> i = []
> item = QgsColorRampShader.ColorRampItem(10, QtGui.QColor('#ffff00'), 'foo')
> i.append(item)
> item = QgsColorRampShader.ColorRampItem(100, QtGui.QColor('#ff00ff'), 'bar')
> i.append(item)
> item = QgsColorRampShader.ColorRampItem(1000, QtGui.QColor('#00ff00'), 'kazam')
> i.append(item)
> c.setColorRampItemList(i)
> s.setRasterShaderFunction(c)
> ######## crash on next line ##################
> ps = QgsSingleBandPseudoColorRenderer(r.dataProvider(), 1,  s)
> r.setRenderer(ps)
>
>
>
> --
> Tim Sutton - QGIS Project Steering Committee Member (Release  Manager)
> ==============================================
> Please do not email me off-list with technical
> support questions. Using the lists will gain
> more exposure for your issues and the knowledge
> surrounding your issue will be shared with all.
>
> Visit http://linfiniti.com to find out about:
>  * QGIS programming and support services
>  * Mapserver and PostGIS based hosting plans
>  * FOSS Consulting Services
> Skype: timlinux
> Irc: timlinux on #qgis at freenode.net
> ==============================================



-- 
Tim Sutton - QGIS Project Steering Committee Member (Release  Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
 * QGIS programming and support services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================


More information about the Qgis-developer mailing list