File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -5412,16 +5412,37 @@ bool QgsRasterLayer::readFile( QString const &theFilename )
5412
5412
// we know we have at least 2 layers...
5413
5413
mRedBandName = bandName ( myQSettings.value ( " /Raster/defaultRedBand" , 1 ).toInt () ); // sensible default
5414
5414
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
+
5415
5427
// for the third layer we cant be sure so..
5416
5428
if ( GDALGetRasterCount ( mGdalDataset ) > 2 )
5417
5429
{
5418
5430
mBlueBandName = bandName ( myQSettings.value ( " /Raster/defaultBlueBand" , 3 ).toInt () ); // sensible default
5431
+ if ( mBlueBandName .isEmpty () )
5432
+ {
5433
+ mBlueBandName = bandName ( 3 );
5434
+ }
5419
5435
}
5420
5436
else
5421
5437
{
5422
5438
mBlueBandName = bandName ( myQSettings.value ( " /Raster/defaultBlueBand" , 2 ).toInt () ); // sensible default
5439
+ if ( mBlueBandName .isEmpty () )
5440
+ {
5441
+ mBlueBandName = bandName ( 2 );
5442
+ }
5423
5443
}
5424
5444
5445
+
5425
5446
mTransparencyBandName = TRSTRING_NOT_SET;
5426
5447
mGrayBandName = TRSTRING_NOT_SET; // sensible default
5427
5448
mDrawingStyle = MultiBandColor; // sensible default
You can’t perform that action at this time.
0 commit comments