Skip to content

Commit

Permalink
Also delay initial preview job by a short timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 17, 2017
1 parent 6c17577 commit 628a1b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@ const QgsLabelingEngineSettings &QgsMapCanvas::labelingEngineSettings() const
void QgsMapCanvas::startPreviewJobs()
{
stopPreviewJobs(); //just in case still running
startPreviewJob( 0 );
schedulePreviewJob( 0 );
}

void QgsMapCanvas::startPreviewJob( int number )
Expand Down Expand Up @@ -2167,15 +2167,7 @@ void QgsMapCanvas::startPreviewJob( int number )

if ( number < 8 )
{
mPreviewTimer.setSingleShot( true );
mPreviewTimer.setInterval( 250 );
disconnect( mPreviewTimerConnection );
mPreviewTimerConnection = connect( &mPreviewTimer, &QTimer::timeout, [ = ]()
{
startPreviewJob( number + 1 );
}
);
mPreviewTimer.start();
schedulePreviewJob( number + 1 );
}
}

Expand All @@ -2194,3 +2186,16 @@ void QgsMapCanvas::stopPreviewJobs()
}
mPreviewJobs.clear();
}

void QgsMapCanvas::schedulePreviewJob( int number )
{
mPreviewTimer.setSingleShot( true );
mPreviewTimer.setInterval( 250 );
disconnect( mPreviewTimerConnection );
mPreviewTimerConnection = connect( &mPreviewTimer, &QTimer::timeout, [ = ]()
{
startPreviewJob( number );
}
);
mPreviewTimer.start();
}
1 change: 1 addition & 0 deletions src/gui/qgsmapcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView

void startPreviewJobs();
void stopPreviewJobs();
void schedulePreviewJob( int number );

friend class TestQgsMapCanvas;

Expand Down

0 comments on commit 628a1b0

Please sign in to comment.