[QGIS-trac] Re: [Quantum GIS] #1480: Strange behavior of set default qml style for indexed rasters

Quantum GIS qgis at qgis.org
Thu Jan 8 10:37:18 EST 2009


#1480: Strange behavior of set default qml style for indexed rasters
-----------------------------------------------------+----------------------
        Reporter:  gislab                            |         Owner:  ersts        
            Type:  bug                               |        Status:  assigned     
        Priority:  major: does not work as expected  |     Milestone:  Version 1.0.1
       Component:  Rasters                           |       Version:  HEAD         
      Resolution:                                    |      Keywords:               
Platform_version:                                    |      Platform:  All          
        Must_fix:  No                                |   Status_info:  0            
-----------------------------------------------------+----------------------
Changes (by ersts):

  * status:  new => assigned
  * owner:  nobody => ersts

Comment:

 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.

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/1480#comment:1>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list