Skip to content
Permalink
Browse files

Avoid QgsFeedback flooding progress report signals

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 5f02e9c89d1b2a43353dcf961cccbb9289a8d989
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/core/qgsfeedback.h
@@ -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

0 comments on commit 5f02e9c

Please sign in to comment.
You can’t perform that action at this time.