Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#1480 closed bug (fixed)

Strange behavior of set default qml style for indexed rasters

Reported by: gislab Owned by: ersts
Priority: major: does not work as expected Milestone:
Component: Rasters Version: Trunk
Keywords: Cc: warmerdam
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

Description

  • Load indexed raster
  • Open properties
  • Color table
  • Change a couple of colors
  • Save as default
  • Ok
  • Try to load the same raster or remove it and try to load it

Is it either not loaded (win) or crashes QGIS (linux)

tested on this raster: http://gis-lab.info/other/indexed-raster-topo1km.7z

Change History (5)

comment:1 by ersts, 15 years ago

Owner: changed from nobody to ersts
Status: newassigned

I actually see several problems and I am surprised they have not come up before...

Part of the back trace:

#0  0xb6d0a845 in GDALClose () from /usr/lib/libgdal1.5.0.so.1
#1  0xb7f48de7 in ~QgsRasterLayer (this=0x9a6e1d0) at 
/home/pete/devel/qgis/trunk-debug/src/core/raster/qgsrasterlayer.cpp:202
#2  0x080e988e in QgisApp::addRasterLayer (this=0x96b8f80, theRasterLayer=0x9a6e1d0) at
 /home/pete/devel/qgis/trunk-debug/src/app/qgisapp.cpp:5107
#3  0x080e9aca in QgisApp::addRasterLayers (this=0x96b8f80, theFileNameQStringList=@0xbfcb86b8,
 guiWarning=true) at /home/pete/devel/qgis/trunk-debug/src/app/qgisapp.cpp:5306
#4  0x080f2d19 in QgisApp::addRasterLayer (this=0x96b8f80) at 
/home/pete/devel/qgis/trunk-debug/src/app/qgisapp.cpp:5079

First issue is that the load default styles call is being made before a raster layer is actually loaded and set_blah_BandName( ) makes a call to validateBandName() which check to see if the band name actually exists, but since a raster layer has not yet be loaded all validation requests will fail and any/all bands will be set to "Not Set", but that is not what causes the crash.

Second problem and a more important one is that the load default styles is returning false, which makes the constructor abort mid way, again before a valid layer is loaded. The loading of the raster layer is where the "isValid" variable gets set, which is not initialized before hand. So when default styles kicks back to the qgisapp.cpp around line 5107 is check to see if the raster layer is valid, if not the raster layer is delete. Because the variable is not initialized,sometime it is true and sometimes it is false which could explain why it sometimes crashes and sometimes does not. But the actual crash is the third problem.

The Third problem is that the in the deconstructor GDALClose is being called on the wrong pointer, which is not checked to see if it is null. This is what actually causes the crash, because if the raster layer has not been loaded, it going to be null.

Sorry for the long post, it is partially to help remember at a later date. I am sure there is going to be a quick release of small bug fixes shortly after v1.0.0 is released.

comment:2 by warmerdam, 15 years ago

Cc: warmerdam added

comment:3 by jctull, 15 years ago

This seems to also occur if setting raster transparency only and saving as a default.

comment:4 by ersts, 15 years ago

Resolution: fixed
Status: assignedclosed

I will let this sit in trunk for a couple of days before shifting over to the Vesion-1_0 branch so a little more testing can be done

comment:5 by (none), 15 years ago

Milestone: Version 1.0.1

Milestone Version 1.0.1 deleted

Note: See TracTickets for help on using tickets.