Skip to content

Commit

Permalink
Avoid QgsFeedback flooding progress report signals
Browse files Browse the repository at this point in the history
We only emit the progress changed signal when there's been at
least a 0.1% change since the last progress report. Otherwise
it's possible that things like processing algorithms which
are reporting feedback every feature in a 500k feature dataset
cause a gazillion signals to be emitted and everything to
slow to a crawl
  • Loading branch information
nyalldawson committed Jul 6, 2017
1 parent e9e335a commit 5f02e9c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/qgsfeedback.h
Expand Up @@ -69,7 +69,14 @@ class CORE_EXPORT QgsFeedback : public QObject
* \see progressChanged()
* \since QGIS 3.0
*/
void setProgress( double progress ) { mProgress = progress; emit progressChanged( mProgress ); }
void setProgress( double progress )
{
// avoid flooding with too many events
if ( static_cast< int >( mProgress * 10 ) != static_cast< int >( progress * 10 ) )
emit progressChanged( progress );

mProgress = progress;
}

/**
* Returns the current progress reported by the feedback object. Depending on how the
Expand Down

0 comments on commit 5f02e9c

Please sign in to comment.