mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-13 00:07:27 -05:00
Add method to QgsRasterBlockFeedback to collect error messages
And append raster errors to rendering errors whenever encountered
This commit is contained in:
parent
230c62fad6
commit
60deffbfa8
@ -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
|
||||
|
||||
};
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user