Skip to content

Commit

Permalink
Allow vector rendering cancelation to also cancel feature iteration f…
Browse files Browse the repository at this point in the history
…or that request

Connect the cancel rendering signal to the iteration cancelation.
This allows providers (e.g. WFS, AFS) to abort slow network requests
when they have been triggered by a render request and that request
is no longer required.

Allows much faster quit, render cancelation when using WFS/AFS layers.

(cherry picked from commit 6fa3bf8)
  • Loading branch information
nyalldawson committed Feb 3, 2019
1 parent fad0861 commit f5ca7b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/core/qgsvectorlayerrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
QgsVectorLayerRenderer::QgsVectorLayerRenderer( QgsVectorLayer *layer, QgsRenderContext &context )
: QgsMapLayerRenderer( layer->id() )
, mContext( context )
, mInterruptionChecker( context )
, mInterruptionChecker( qgis::make_unique< QgsVectorLayerRendererInterruptionChecker >( context ) )
, mLayer( layer )
, mFields( layer->fields() )
, mLabeling( false )
Expand Down Expand Up @@ -106,6 +106,10 @@ QgsVectorLayerRenderer::~QgsVectorLayerRenderer()
delete mSource;
}

QgsFeedback *QgsVectorLayerRenderer::feedback() const
{
return mInterruptionChecker.get();
}

bool QgsVectorLayerRenderer::render()
{
Expand Down Expand Up @@ -239,7 +243,7 @@ bool QgsVectorLayerRenderer::render()
// slow fetchFeature() implementations, such as in the WFS provider, can
// check it, instead of relying on just the mContext.renderingStopped() check
// in drawRenderer()
fit.setInterruptionChecker( &mInterruptionChecker );
fit.setInterruptionChecker( mInterruptionChecker.get() );

if ( ( mRenderer->capabilities() & QgsFeatureRenderer::SymbolLevels ) && mRenderer->usingSymbolLevels() )
drawRendererLevels( fit );
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsvectorlayerrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class QgsVectorLayerRenderer : public QgsMapLayerRenderer
public:
QgsVectorLayerRenderer( QgsVectorLayer *layer, QgsRenderContext &context );
~QgsVectorLayerRenderer() override;
QgsFeedback *feedback() const override;

bool render() override;

Expand Down Expand Up @@ -107,7 +108,7 @@ class QgsVectorLayerRenderer : public QgsMapLayerRenderer

QgsRenderContext &mContext;

QgsVectorLayerRendererInterruptionChecker mInterruptionChecker;
std::unique_ptr< QgsVectorLayerRendererInterruptionChecker > mInterruptionChecker;

//! The rendered layer
QgsVectorLayer *mLayer = nullptr;
Expand Down

0 comments on commit f5ca7b7

Please sign in to comment.