diff --git a/python/core/auto_generated/raster/qgsrasterinterface.sip.in b/python/core/auto_generated/raster/qgsrasterinterface.sip.in index a0254f3af88..f09d8994c04 100644 --- a/python/core/auto_generated/raster/qgsrasterinterface.sip.in +++ b/python/core/auto_generated/raster/qgsrasterinterface.sip.in @@ -61,6 +61,25 @@ Whether our painter is drawing to a temporary image used just by this layer Set whether our painter is drawing to a temporary image used just by this layer .. seealso:: :py:func:`renderPartialOutput` +%End + + void appendError( const QString &error ); +%Docstring +Appends an error message to the stored list of errors. Should be called +whenever an error is encountered while retrieving a raster block. + +.. seealso:: :py:func:`errors` + +.. versionadded:: 3.8.0 +%End + + QStringList errors() const; +%Docstring +Returns a list of any errors encountered while retrieving the raster block. + +.. seealso:: :py:func:`appendError` + +.. versionadded:: 3.8.0 %End }; diff --git a/src/core/raster/qgsrasterinterface.h b/src/core/raster/qgsrasterinterface.h index cf9f0d7aa5f..c08e6a25a22 100644 --- a/src/core/raster/qgsrasterinterface.h +++ b/src/core/raster/qgsrasterinterface.h @@ -76,6 +76,23 @@ class CORE_EXPORT QgsRasterBlockFeedback : public QgsFeedback */ void setRenderPartialOutput( bool enable ) { mRenderPartialOutput = enable; } + /** + * Appends an error message to the stored list of errors. Should be called + * whenever an error is encountered while retrieving a raster block. + * + * \see errors() + * \since QGIS 3.8.0 + */ + void appendError( const QString &error ) { mErrors.append( error ); } + + /** + * Returns a list of any errors encountered while retrieving the raster block. + * + * \see appendError() + * \since QGIS 3.8.0 + */ + QStringList errors() const { return mErrors; } + private: /** @@ -86,6 +103,9 @@ class CORE_EXPORT QgsRasterBlockFeedback : public QgsFeedback //! Whether our painter is drawing to a temporary image used just by this layer bool mRenderPartialOutput = false; + + //! List of errors encountered while retrieving block + QStringList mErrors; }; diff --git a/src/core/raster/qgsrasterlayerrenderer.cpp b/src/core/raster/qgsrasterlayerrenderer.cpp index 9c9f99af0a8..3d9e231f213 100644 --- a/src/core/raster/qgsrasterlayerrenderer.cpp +++ b/src/core/raster/qgsrasterlayerrenderer.cpp @@ -272,6 +272,12 @@ bool QgsRasterLayerRenderer::render() QgsRasterDrawer drawer( &iterator ); drawer.draw( mPainter, mRasterViewPort, mMapToPixel, mFeedback ); + const QStringList errors = mFeedback->errors(); + for ( const QString &error : errors ) + { + mErrors.append( error ); + } + QgsDebugMsgLevel( QStringLiteral( "total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ), 4 ); return true; diff --git a/src/providers/arcgisrest/qgsamsprovider.cpp b/src/providers/arcgisrest/qgsamsprovider.cpp index 79cfdcc0b11..876de010ff3 100644 --- a/src/providers/arcgisrest/qgsamsprovider.cpp +++ b/src/providers/arcgisrest/qgsamsprovider.cpp @@ -463,6 +463,9 @@ bool QgsAmsProvider::readBlock( int /*bandNo*/, const QgsRectangle &viewExtent, draw( viewExtent, width, height ); if ( mCachedImage.width() != width || mCachedImage.height() != height ) { + if ( feedback ) + feedback->appendError( tr( "Unexpected image size for block" ) ); + QgsDebugMsg( QStringLiteral( "Unexpected image size for block" ) ); return false; } diff --git a/src/providers/gdal/qgsgdalprovider.cpp b/src/providers/gdal/qgsgdalprovider.cpp index 422e3440820..f82194ecae5 100644 --- a/src/providers/gdal/qgsgdalprovider.cpp +++ b/src/providers/gdal/qgsgdalprovider.cpp @@ -904,7 +904,11 @@ bool QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pi if ( err != CPLE_None ) { - QgsLogger::warning( "RasterIO error: " + QString::fromUtf8( CPLGetLastErrorMsg() ) ); + const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ) ; + if ( feedback ) + feedback->appendError( lastError ); + + QgsLogger::warning( "RasterIO error: " + lastError ); qgsFree( tmpBlock ); return false; }