Skip to content
Permalink
Browse files

Set gathered statistics to none when there are no statistics

Fixes #41662

(cherry picked from commit caa1917)
  • Loading branch information
elpaso authored and nyalldawson committed Mar 19, 2021
1 parent 03d20e0 commit 972afd368168548c2995e0a10aba017b1d161c0f
Showing with 6 additions and 2 deletions.
  1. +4 −0 src/core/providers/gdal/qgsgdalprovider.cpp
  2. +2 −2 src/core/raster/qgsrasterlayer.cpp
@@ -2863,6 +2863,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;
@@ -982,8 +982,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 972afd3

Please sign in to comment.