Skip to content

Commit

Permalink
[GRASS] do not show 100% progress until module finished, fixes #3131
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Feb 23, 2016
1 parent 9197e1e commit b952f0f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/plugins/grass/qgsgrassmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ void QgsGrassModule::finished( int exitCode, QProcess::ExitStatus exitStatus )
if ( exitCode == 0 )
{
mOutputTextBrowser->append( tr( "<B>Successfully finished</B>" ) );
mProgressBar->setValue( 100 );
setProgress( 100, true );
mSuccess = true;
mViewButton->setEnabled( !mOutputVector.isEmpty() || !mOutputRaster.isEmpty() );
mOptions->freezeOutput( false );
Expand Down Expand Up @@ -784,7 +784,7 @@ void QgsGrassModule::readStdout()
if ( rxpercent.indexIn( line ) != -1 )
{
int progress = rxpercent.cap( 1 ).toInt();
mProgressBar->setValue( progress );
setProgress( progress );
}
else
{
Expand All @@ -810,7 +810,7 @@ void QgsGrassModule::readStderr()
QgsGrass::ModuleOutput type = QgsGrass::parseModuleOutput( line, text, html, percent );
if ( type == QgsGrass::OutputPercent )
{
mProgressBar->setValue( percent );
setProgress( percent );
}
else if ( type == QgsGrass::OutputMessage || type == QgsGrass::OutputWarning || type == QgsGrass::OutputError )
{
Expand All @@ -819,6 +819,19 @@ void QgsGrassModule::readStderr()
}
}

void QgsGrassModule::setProgress( int percent, bool force )
{
int max = 100;
// Do not set 100% until module finished, see #3131
if ( percent >= 100 && !force )
{
max = 0; // busy indicator
percent = 0;
}
mProgressBar->setMaximum( max );
mProgressBar->setValue( percent );
}

void QgsGrassModule::close()
{
delete this;
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/grass/qgsgrassmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ class QgsGrassModule : public QWidget, private Ui::QgsGrassModuleBase
//void mapsetChanged();

private:
/** Set progress bar or busy indicator if percent is 100
* @param percent progress to show in %
* @param force to set progress for 100% */
void setProgress( int percent, bool force = false );

//! Pointer to the QGIS interface object
QgisInterface *mIface;

Expand Down

0 comments on commit b952f0f

Please sign in to comment.