Skip to content

Commit 5f02e9c

Browse files
committed
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
1 parent e9e335a commit 5f02e9c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/core/qgsfeedback.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ class CORE_EXPORT QgsFeedback : public QObject
6969
* \see progressChanged()
7070
* \since QGIS 3.0
7171
*/
72-
void setProgress( double progress ) { mProgress = progress; emit progressChanged( mProgress ); }
72+
void setProgress( double progress )
73+
{
74+
// avoid flooding with too many events
75+
if ( static_cast< int >( mProgress * 10 ) != static_cast< int >( progress * 10 ) )
76+
emit progressChanged( progress );
77+
78+
mProgress = progress;
79+
}
7380

7481
/**
7582
* Returns the current progress reported by the feedback object. Depending on how the

0 commit comments

Comments
 (0)