[QGIS-Developer] Error with raster renderer in QGIS 3.10

SSchmidt at gfi-gis.de SSchmidt at gfi-gis.de
Thu Nov 14 02:27:18 PST 2019


Hello,

in my plugin I set up a rasterlayer like this:

QgsRasterLayer* lyr = new QgsRasterLayer(src->Dir + "/" + src->File, 
firstTBLayer->Title, QStringLiteral("gdal"));
if (lyr->isValid())
        QgsProject::instance()->addMapLayers(QList<QgsMapLayer *>() << 
lyr, false);

The layer is valid and in a next step I ask for the renderer ... qgis 
crashes because of heap corruption.

So I create a new renderer like this:

QgsRasterRenderer* rend = new QgsMultiBandColorRenderer
(rLyr->dataProvider(), redBand, greenBand, blueBand);
rLyr->setRenderer(rend);

In QGIS all seems to be OK but while closing QGIS it crashes again.
If I ask for the renderer
qDebug() << rLyr->renderer();

QGIS crashes with following messages:

Ausnahme ausgelöst bei 0x00007ffd5369c3f0 in qgis-bin.exe: 0xC0000005: 
Zugriffsverletzung beim Lesen an Position 0x0000000000000030.

Stack Trace:

QgsRasterPipe::interface qgsrasterpipe.cpp:225
QgsRasterPipe::renderer qgsrasterpipe.cpp:239
QGISFunc::ReadRasterRuleSLD qgisfunc.cpp:1779


What is changing in my plugin while updating from qgis 2.18 to 3.10 ? The 
layer is added to legend after manipulating the renderer. In old plugin I 
manipulate renderer after adding it to legend. But this seems to be not 
the problem.

Anyone who can help, please?

Freundliche Grüße aus Leipzig
Susann Schmidt
Softwareentwicklung 

**************************************************************

GFI - Gesellschaft für Informationstechnologie mbH
Philipp-Rosenthal-Straße 9
D-04103 Leipzig
Geschäftsführer: Andreas Richter
Amtsgericht Leipzig HRB 12054
USt.-IdNr.: DE179049354     Steuer-Nr.: 231/109/06412
ESRI Solution Partner      und       ER Mapper Reseller
Tel. 0341 961 3310    Fax 0341 961 3311   Mail info at gfi-gis.de
Web  www.gfi-gis.de  und  www.themenbrowser.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20191114/75cef32c/attachment.html>


More information about the QGIS-Developer mailing list