Skip to content

Commit

Permalink
Fix thread unsafe progress reporting from GDAL operations
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Dec 15, 2022
1 parent bf0533b commit 063ae8c
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/core/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -108,27 +108,15 @@ int CPL_STDCALL progressCallback( double dfComplete,
{
Q_UNUSED( pszMessage )

static double sDfLastComplete = -1.0;

QgsGdalProgress *prog = static_cast<QgsGdalProgress *>( pProgressArg );

if ( sDfLastComplete > dfComplete )
if ( QgsRasterBlockFeedback *feedback = prog->feedback )
{
if ( sDfLastComplete >= 1.0 )
sDfLastComplete = -1.0;
else
sDfLastComplete = dfComplete;
}
feedback->setProgress( dfComplete * 100 );

if ( std::floor( sDfLastComplete * 10 ) != std::floor( dfComplete * 10 ) )
{
if ( prog->feedback )
prog->feedback->setProgress( dfComplete * 100 );
if ( feedback->isCanceled() )
return false;
}
sDfLastComplete = dfComplete;

if ( prog->feedback && prog->feedback->isCanceled() )
return false;

return true;
}
Expand Down

0 comments on commit 063ae8c

Please sign in to comment.