Skip to content

Commit

Permalink
fix crash with emtpy inputBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
root676 authored and nyalldawson committed Aug 5, 2020
1 parent aefb114 commit 8a61f8f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/analysis/processing/qgsalgorithmrasterstackposition.cpp
Expand Up @@ -164,18 +164,26 @@ QVariantMap QgsRasterStackPositionAlgorithmBase::processAlgorithm( const QVarian
for ( int col = 0; col < iterCols; col++ )
{
bool noDataInStack = false;
int position = findPosition( inputBlocks, row, col, noDataInStack );

if ( position == -1 || ( noDataInStack && !mIgnoreNoData ) )
if ( !inputBlocks.empty() )
{
//output cell will always be NoData if NoData occurs the current raster cell
//of the input blocks and NoData is not ignored
//this saves unnecessary iterations on the cellValueStack
outputBlock->setValue( row, col, mNoDataValue );
int position = findPosition( inputBlocks, row, col, noDataInStack );

if ( position == -1 || ( noDataInStack && !mIgnoreNoData ) )
{
//output cell will always be NoData if NoData occurs the current raster cell
//of the input blocks and NoData is not ignored
//this saves unnecessary iterations on the cellValueStack
outputBlock->setValue( row, col, mNoDataValue );
}
else
{
outputBlock->setValue( row, col, position );
}
}
else
{
outputBlock->setValue( row, col, position );
outputBlock->setValue( row, col, mNoDataValue );
}
}
}
Expand Down

0 comments on commit 8a61f8f

Please sign in to comment.