Skip to content

Commit

Permalink
Run canvas preview jobs sequentially
Browse files Browse the repository at this point in the history
Only start the next job when the previous one has completely finished.
Avoids flooding connection pools with too many quick requests.
  • Loading branch information
nyalldawson committed Dec 4, 2017
1 parent 01e8ed8 commit 91c9130
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -634,6 +634,13 @@ void QgsMapCanvas::previewJobFinished()
{
mMap->addPreviewImage( job->renderedImage(), job->mapSettings().extent() );
mPreviewJobs.removeAll( job );

int number = job->property( "number" ).toInt();
if ( number < 8 )
{
startPreviewJob( number + 1 );
}

delete job;
}
}
Expand Down Expand Up @@ -2289,14 +2296,10 @@ void QgsMapCanvas::startPreviewJob( int number )
jobSettings.setLayers( previewLayers );

QgsMapRendererQImageJob *job = new QgsMapRendererSequentialJob( jobSettings );
job->setProperty( "number", number );
mPreviewJobs.append( job );
connect( job, &QgsMapRendererJob::finished, this, &QgsMapCanvas::previewJobFinished );
job->start();

if ( number < 8 )
{
schedulePreviewJob( number + 1 );
}
}

void QgsMapCanvas::stopPreviewJobs()
Expand Down

0 comments on commit 91c9130

Please sign in to comment.