Skip to content
Permalink
Browse files

Merge pull request #4830 from nyalldawson/fix_categorised_render_crash

Fix categorised render crash
  • Loading branch information
nyalldawson committed Jul 11, 2017
2 parents ff5181c + 7db483d commit eec19de2ed5580e708e348bac9bd7df054dc9258
@@ -445,12 +445,6 @@ void QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext& context, con
mTempSymbols[ cat.symbol()] = tempSymbol;
}
}

Q_FOREACH ( QgsSymbolV2 *symbol, mSymbolHash.values() )
{
symbol->startRender( context, &fields );
}

return;
}

@@ -461,11 +455,6 @@ void QgsCategorizedSymbolRendererV2::stopRender( QgsRenderContext& context )
cat.symbol()->stopRender( context );
}

Q_FOREACH ( QgsSymbolV2 *symbol, mSymbolHash.values() )
{
symbol->stopRender( context );
}

// cleanup mTempSymbols
QHash<QgsSymbolV2*, QgsSymbolV2*>::const_iterator it2 = mTempSymbols.constBegin();
for ( ; it2 != mTempSymbols.constEnd(); ++it2 )
@@ -89,9 +89,9 @@ QgsSymbolV2::QgsSymbolV2( SymbolType type, const QgsSymbolLayerV2List& layers )
, mRenderHints( 0 )
, mClipFeaturesToExtent( true )
, mLayer( nullptr )
, mStarted( false )
, mSymbolRenderContext( nullptr )
{

// check they're all correct symbol layers
for ( int i = 0; i < mLayers.count(); i++ )
{
@@ -444,6 +444,9 @@ bool QgsSymbolV2::changeSymbolLayer( int index, QgsSymbolLayerV2* layer )

void QgsSymbolV2::startRender( QgsRenderContext& context, const QgsFields* fields )
{
Q_ASSERT_X( !mStarted, "startRender", "Rendering has already been started for this symbol instance!" );

mStarted = true;
delete mSymbolRenderContext;
mSymbolRenderContext = new QgsSymbolV2RenderContext( context, outputUnit(), mAlpha, false, mRenderHints, nullptr, fields, mapUnitScale() );

@@ -459,6 +462,9 @@ void QgsSymbolV2::startRender( QgsRenderContext& context, const QgsFields* field

void QgsSymbolV2::stopRender( QgsRenderContext& context )
{
Q_ASSERT_X( mStarted, "startRender", "startRender was not called for this symbol instance!" );
mStarted = false;

Q_UNUSED( context )
if ( mSymbolRenderContext )
{
@@ -335,6 +335,9 @@ class CORE_EXPORT QgsSymbolV2
const QgsVectorLayer* mLayer; //current vectorlayer

private:
//! True if render has already been started - guards against multiple calls to
//! startRender() (usually a result of not cloning a shared symbol instance before rendering).
bool mStarted;
//! Initialized in startRender, destroyed in stopRender
QgsSymbolV2RenderContext* mSymbolRenderContext;

0 comments on commit eec19de

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