Skip to content

Commit b952f0f

Browse files
committedFeb 23, 2016
[GRASS] do not show 100% progress until module finished, fixes #3131
1 parent 9197e1e commit b952f0f

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed
 

‎src/plugins/grass/qgsgrassmodule.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ void QgsGrassModule::finished( int exitCode, QProcess::ExitStatus exitStatus )
746746
if ( exitCode == 0 )
747747
{
748748
mOutputTextBrowser->append( tr( "<B>Successfully finished</B>" ) );
749-
mProgressBar->setValue( 100 );
749+
setProgress( 100, true );
750750
mSuccess = true;
751751
mViewButton->setEnabled( !mOutputVector.isEmpty() || !mOutputRaster.isEmpty() );
752752
mOptions->freezeOutput( false );
@@ -784,7 +784,7 @@ void QgsGrassModule::readStdout()
784784
if ( rxpercent.indexIn( line ) != -1 )
785785
{
786786
int progress = rxpercent.cap( 1 ).toInt();
787-
mProgressBar->setValue( progress );
787+
setProgress( progress );
788788
}
789789
else
790790
{
@@ -810,7 +810,7 @@ void QgsGrassModule::readStderr()
810810
QgsGrass::ModuleOutput type = QgsGrass::parseModuleOutput( line, text, html, percent );
811811
if ( type == QgsGrass::OutputPercent )
812812
{
813-
mProgressBar->setValue( percent );
813+
setProgress( percent );
814814
}
815815
else if ( type == QgsGrass::OutputMessage || type == QgsGrass::OutputWarning || type == QgsGrass::OutputError )
816816
{
@@ -819,6 +819,19 @@ void QgsGrassModule::readStderr()
819819
}
820820
}
821821

822+
void QgsGrassModule::setProgress( int percent, bool force )
823+
{
824+
int max = 100;
825+
// Do not set 100% until module finished, see #3131
826+
if ( percent >= 100 && !force )
827+
{
828+
max = 0; // busy indicator
829+
percent = 0;
830+
}
831+
mProgressBar->setMaximum( max );
832+
mProgressBar->setValue( percent );
833+
}
834+
822835
void QgsGrassModule::close()
823836
{
824837
delete this;

‎src/plugins/grass/qgsgrassmodule.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ class QgsGrassModule : public QWidget, private Ui::QgsGrassModuleBase
125125
//void mapsetChanged();
126126

127127
private:
128+
/** Set progress bar or busy indicator if percent is 100
129+
* @param percent progress to show in %
130+
* @param force to set progress for 100% */
131+
void setProgress( int percent, bool force = false );
132+
128133
//! Pointer to the QGIS interface object
129134
QgisInterface *mIface;
130135

0 commit comments

Comments
 (0)
Please sign in to comment.