Skip to content
Permalink
Browse files

Set gathered statistics to none when there are no statistics

Fixes #41662
  • Loading branch information
elpaso committed Feb 19, 2021
1 parent 30b2166 commit caa19170ba3e14b8a2db4cef7a24a3a0e247d096
Showing with 6 additions and 2 deletions.
  1. +4 −0 src/core/providers/gdal/qgsgdalprovider.cpp
  2. +2 −2 src/core/raster/qgsrasterlayer.cpp
@@ -2882,6 +2882,10 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int bandNo, int stats, const
QgsDebugMsgLevel( QStringLiteral( "STDDEV %1" ).arg( myRasterBandStats.stdDev ), 2 );
#endif
}
else
{
myRasterBandStats.statsGathered = QgsRasterBandStats::Stats::None;
}

mStatistics.append( myRasterBandStats );
return myRasterBandStats;
@@ -992,8 +992,8 @@ void QgsRasterLayer::computeMinMax( int band,
if ( limits == QgsRasterMinMaxOrigin::MinMax )
{
QgsRasterBandStats myRasterBandStats = mDataProvider->bandStatistics( band, QgsRasterBandStats::Min | QgsRasterBandStats::Max, extent, sampleSize );
// Check if statistics were actually gathered, 0 means a failure
if ( myRasterBandStats.elementCount == 0 )
// Check if statistics were actually gathered, None means a failure
if ( myRasterBandStats.statsGathered == QgsRasterBandStats::Stats::None )
{
// Best guess we can do
switch ( mDataProvider->dataType( band ) )

0 comments on commit caa1917

Please sign in to comment.