[Qgis-developer] How to load a colour table on a raster, programmatically (in python)?

Martin Dobias wonder.sk at gmail.com
Tue Aug 10 15:46:56 EDT 2010


On Mon, Aug 9, 2010 at 9:57 PM, Peter Ersts <ersts at amnh.org> wrote:
> ---theLayer.setRasterShaderFunction( myColorRampShader ) is also not
> necessary, because you are already working with the actual shader (i.e.,
> myColorRampShader ). This will also cause a crash/segfault because the
> setRasterShaderFunction() now is deleting the existing function and
> replacing it with the new, however, in this case it is deleting itself.
> MARTIN: This was why QgsRasterLayer managed deleting the functions and
> checked to see if the QgsRasterShaderFunction was user defined. I saw too
> many possibilities for crashes if the shader itself managed the deleting of
> functions. This case illustrates on instance of that problem.

Hi Pete,

I believe this can be fixed easily by testing whether the new shader
function isn't the same as the previous one in
setRasterShaderFunction(). Do you see any further scenarios that might
lead to a crash? Because deleting the shader function in the class
where it belongs is typically less prone to memory leaks or double
deletion.

Bye
Martin


More information about the Qgis-developer mailing list