Skip to content

Commit a2a9a28

Browse files
author
ersts
committed
-Added check to make sure preferred bands combinations are valid
-Closes ticket #1852 git-svn-id: http://svn.osgeo.org/qgis/trunk@14032 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent d5e0f6b commit a2a9a28

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/core/raster/qgsrasterlayer.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5412,16 +5412,37 @@ bool QgsRasterLayer::readFile( QString const &theFilename )
54125412
//we know we have at least 2 layers...
54135413
mRedBandName = bandName( myQSettings.value( "/Raster/defaultRedBand", 1 ).toInt() ); // sensible default
54145414
mGreenBandName = bandName( myQSettings.value( "/Raster/defaultGreenBand", 2 ).toInt() ); // sensible default
5415+
5416+
//Check to make sure preferred bands combinations are valid
5417+
if ( mRedBandName.isEmpty() )
5418+
{
5419+
mRedBandName = bandName( 1 );
5420+
}
5421+
5422+
if ( mGreenBandName.isEmpty() )
5423+
{
5424+
mGreenBandName = bandName( 2 );
5425+
}
5426+
54155427
//for the third layer we cant be sure so..
54165428
if ( GDALGetRasterCount( mGdalDataset ) > 2 )
54175429
{
54185430
mBlueBandName = bandName( myQSettings.value( "/Raster/defaultBlueBand", 3 ).toInt() ); // sensible default
5431+
if ( mBlueBandName.isEmpty() )
5432+
{
5433+
mBlueBandName = bandName( 3 );
5434+
}
54195435
}
54205436
else
54215437
{
54225438
mBlueBandName = bandName( myQSettings.value( "/Raster/defaultBlueBand", 2 ).toInt() ); // sensible default
5439+
if ( mBlueBandName.isEmpty() )
5440+
{
5441+
mBlueBandName = bandName( 2 );
5442+
}
54235443
}
54245444

5445+
54255446
mTransparencyBandName = TRSTRING_NOT_SET;
54265447
mGrayBandName = TRSTRING_NOT_SET; //sensible default
54275448
mDrawingStyle = MultiBandColor; //sensible default

0 commit comments

Comments
 (0)