Skip to content
Permalink
Browse files

Use a clone of the renderer for attribute table model

Fixes potential crash
  • Loading branch information
nyalldawson committed Oct 1, 2017
1 parent a874faf commit dfe0cbafad26f087399816d8b511cfb8ba4f51b5
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/gui/attributetable/qgsattributetablefiltermodel.cpp
@@ -408,24 +408,24 @@ void QgsAttributeTableFilterModel::generateListOfVisibleFeatures()
QgsRectangle rect = mCanvas->mapSettings().mapToLayerCoordinates( layer(), mCanvas->extent() );
QgsRenderContext renderContext;
renderContext.expressionContext().appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( layer() ) );
QgsFeatureRenderer *renderer = layer()->renderer();

mFilteredFeatures.clear();

if ( !renderer )
if ( !layer()->renderer() )
{
QgsDebugMsg( "Cannot get renderer" );
return;
}

std::unique_ptr< QgsFeatureRenderer > renderer( layer()->renderer()->clone() );

const QgsMapSettings &ms = mCanvas->mapSettings();
if ( !layer()->isInScaleRange( ms.scale() ) )
{
QgsDebugMsg( "Out of scale limits" );
}
else
{
if ( renderer && renderer->capabilities() & QgsFeatureRenderer::ScaleDependent )
if ( renderer->capabilities() & QgsFeatureRenderer::ScaleDependent )
{
// setup scale
// mapRenderer()->renderContext()->scale is not automatically updated when
@@ -436,7 +436,7 @@ void QgsAttributeTableFilterModel::generateListOfVisibleFeatures()
renderContext.setRendererScale( ms.scale() );
}

filter = renderer && renderer->capabilities() & QgsFeatureRenderer::Filter;
filter = renderer->capabilities() & QgsFeatureRenderer::Filter;
}

renderer->startRender( renderContext, layer()->fields() );
@@ -476,7 +476,7 @@ void QgsAttributeTableFilterModel::generateListOfVisibleFeatures()

features.close();

if ( renderer && renderer->capabilities() & QgsFeatureRenderer::ScaleDependent )
if ( renderer->capabilities() & QgsFeatureRenderer::ScaleDependent )
{
renderer->stopRender( renderContext );
}

0 comments on commit dfe0cba

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