Skip to content

Commit 47a90e9

Browse files
committed
[processing] Fix algorithm progress bar resets to 0 when an algorithm
reports a non-fatal error Fixes the "flashy" progress bar when an algorithm encounters a lot of errors. (cherry-picked from 654a4a4)
1 parent 2700f77 commit 47a90e9

File tree

8 files changed

+28
-21
lines changed

8 files changed

+28
-21
lines changed

python/core/processing/qgsprocessingfeedback.sip.in

+5-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ setProgress() to provide detailed progress reports, such as "Transformed
3535
.. seealso:: :py:func:`setProgress`
3636
%End
3737

38-
virtual void reportError( const QString &error );
38+
virtual void reportError( const QString &error, bool fatalError = false );
3939
%Docstring
40-
Reports that the algorithm encountered an error which prevented it
41-
from successfully executing.
40+
Reports that the algorithm encountered an ``error`` while executing.
41+
42+
If ``fatalError`` is true then the error prevented the algorithm from executing.
4243
%End
4344

4445
virtual void pushInfo( const QString &info );
@@ -127,7 +128,7 @@ to scale the current progress to account for progress through the overall proces
127128

128129
virtual void setProgressText( const QString &text );
129130

130-
virtual void reportError( const QString &error );
131+
virtual void reportError( const QString &error, bool fatalError );
131132

132133
virtual void pushInfo( const QString &info );
133134

python/gui/processing/qgsprocessingalgorithmdialogbase.sip.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ Returns the parameter values for the algorithm to run in the dialog.
100100
virtual void accept();
101101

102102

103-
void reportError( const QString &error );
103+
void reportError( const QString &error, bool fatalError );
104104
%Docstring
105105
Reports an ``error`` string to the dialog's log.
106+
107+
If ``fatalError`` is true, the error prevented the algorithm from executing.
106108
%End
107109

108110
void pushInfo( const QString &info );

python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(self, dialog):
6767
QgsProcessingFeedback.__init__(self)
6868
self.dialog = dialog
6969

70-
def reportError(self, msg):
70+
def reportError(self, msg, fatal_error):
7171
self.dialog.error(msg)
7272

7373

python/plugins/processing/gui/MessageBarProgress.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, algname=None):
4848
iface.messageBar().pushWidget(self.progressMessageBar,
4949
Qgis.Info)
5050

51-
def reportError(self, msg):
51+
def reportError(self, msg, fatal_error):
5252
self.msg.append(msg)
5353

5454
def close(self):

src/core/processing/qgsprocessingfeedback.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ void QgsProcessingMultiStepFeedback::setProgressText( const QString &text )
3636
mFeedback->setProgressText( text );
3737
}
3838

39-
void QgsProcessingMultiStepFeedback::reportError( const QString &error )
39+
void QgsProcessingMultiStepFeedback::reportError( const QString &error, bool fatalError )
4040
{
41-
mFeedback->reportError( error );
41+
mFeedback->reportError( error, fatalError );
4242
}
4343

4444
void QgsProcessingMultiStepFeedback::pushInfo( const QString &info )

src/core/processing/qgsprocessingfeedback.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
4747
virtual void setProgressText( const QString &text ) { Q_UNUSED( text ); }
4848

4949
/**
50-
* Reports that the algorithm encountered an error which prevented it
51-
* from successfully executing.
50+
* Reports that the algorithm encountered an \a error while executing.
51+
*
52+
* If \a fatalError is true then the error prevented the algorithm from executing.
5253
*/
53-
virtual void reportError( const QString &error ) { QgsMessageLog::logMessage( error ); }
54+
virtual void reportError( const QString &error, bool fatalError = false ) { Q_UNUSED( fatalError ); QgsMessageLog::logMessage( error ); }
5455

5556
/**
5657
* Pushes a general informational message from the algorithm. This can
@@ -125,7 +126,7 @@ class CORE_EXPORT QgsProcessingMultiStepFeedback : public QgsProcessingFeedback
125126
void setCurrentStep( int step );
126127

127128
void setProgressText( const QString &text ) override;
128-
void reportError( const QString &error ) override;
129+
void reportError( const QString &error, bool fatalError ) override;
129130
void pushInfo( const QString &info ) override;
130131
void pushCommandInfo( const QString &info ) override;
131132
void pushDebugInfo( const QString &info ) override;

src/gui/processing/qgsprocessingalgorithmdialogbase.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ void QgsProcessingAlgorithmDialogFeedback::setProgressText( const QString &text
3838
emit progressTextChanged( text );
3939
}
4040

41-
void QgsProcessingAlgorithmDialogFeedback::reportError( const QString &error )
41+
void QgsProcessingAlgorithmDialogFeedback::reportError( const QString &error, bool fatalError )
4242
{
43-
emit errorReported( error );
43+
emit errorReported( error, fatalError );
4444
}
4545

4646
void QgsProcessingAlgorithmDialogFeedback::pushInfo( const QString &info )
@@ -316,10 +316,11 @@ void QgsProcessingAlgorithmDialogBase::closeClicked()
316316
close();
317317
}
318318

319-
void QgsProcessingAlgorithmDialogBase::reportError( const QString &error )
319+
void QgsProcessingAlgorithmDialogBase::reportError( const QString &error, bool fatalError )
320320
{
321321
setInfo( error, true );
322-
resetGui();
322+
if ( fatalError )
323+
resetGui();
323324
showLog();
324325
processEvents();
325326
}
@@ -476,7 +477,7 @@ void QgsProcessingAlgorithmDialogBase::setCurrentTask( QgsProcessingAlgRunnerTas
476477
void QgsProcessingAlgorithmDialogBase::setInfo( const QString &message, bool isError, bool escapeHtml )
477478
{
478479
if ( isError )
479-
txtLog->append( QStringLiteral( "<span style=\"color:red\">%1</span><br />" ).arg( message ) );
480+
txtLog->append( QStringLiteral( "<span style=\"color:red\">%1</span>" ).arg( message ) );
480481
else if ( escapeHtml )
481482
txtLog->append( message.toHtmlEscaped() );
482483
else

src/gui/processing/qgsprocessingalgorithmdialogbase.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class QgsProcessingAlgorithmDialogFeedback : public QgsProcessingFeedback
5454
signals:
5555

5656
void progressTextChanged( const QString &text );
57-
void errorReported( const QString &text );
57+
void errorReported( const QString &text, bool fatalError );
5858
void infoPushed( const QString &text );
5959
void commandInfoPushed( const QString &text );
6060
void debugInfoPushed( const QString &text );
@@ -63,7 +63,7 @@ class QgsProcessingAlgorithmDialogFeedback : public QgsProcessingFeedback
6363
public slots:
6464

6565
void setProgressText( const QString &text ) override;
66-
void reportError( const QString &error ) override;
66+
void reportError( const QString &error, bool fatalError ) override;
6767
void pushInfo( const QString &info ) override;
6868
void pushCommandInfo( const QString &info ) override;
6969
void pushDebugInfo( const QString &info ) override;
@@ -150,8 +150,10 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
150150

151151
/**
152152
* Reports an \a error string to the dialog's log.
153+
*
154+
* If \a fatalError is true, the error prevented the algorithm from executing.
153155
*/
154-
void reportError( const QString &error );
156+
void reportError( const QString &error, bool fatalError );
155157

156158
/**
157159
* Pushes an information string to the dialog's log.

0 commit comments

Comments
 (0)