Skip to content
Permalink
Browse files

[GRASS] do not show 100% progress until module finished, fixes #3131

  • Loading branch information
blazek committed Feb 23, 2016
1 parent 9197e1e commit b952f0f177ed284d29a287cb239f354b13c25462
Showing with 21 additions and 3 deletions.
  1. +16 −3 src/plugins/grass/qgsgrassmodule.cpp
  2. +5 −0 src/plugins/grass/qgsgrassmodule.h
@@ -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 );
@@ -784,7 +784,7 @@ void QgsGrassModule::readStdout()
if ( rxpercent.indexIn( line ) != -1 )
{
int progress = rxpercent.cap( 1 ).toInt();
mProgressBar->setValue( progress );
setProgress( progress );
}
else
{
@@ -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 )
{
@@ -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;
@@ -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;

0 comments on commit b952f0f

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