Skip to content

Commit

Permalink
Followup 7d600bd, proper fix for failing labeling engine test
Browse files Browse the repository at this point in the history
When labelFeatures is called outside of the renderering loop,
we need to make sure the renderer is prepared by calling
startRender.
  • Loading branch information
nyalldawson committed Nov 23, 2015
1 parent ffebfd9 commit f145843
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/core/qgsvectorlayerlabelprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ QList<QgsLabelFeature*> QgsVectorLayerLabelProvider::labelFeatures( QgsRenderCon
if ( !prepare( ctx, attrNames ) )
return QList<QgsLabelFeature*>();

if ( mRenderer )
mRenderer->startRender( ctx, mFields );

QgsRectangle layerExtent = ctx.extent();
if ( mSettings.ct )
layerExtent = mSettings.ct->transformBoundingBox( ctx.extent(), QgsCoordinateTransform::ReverseTransform );
Expand All @@ -278,6 +281,9 @@ QList<QgsLabelFeature*> QgsVectorLayerLabelProvider::labelFeatures( QgsRenderCon
registerFeature( fet, ctx, obstacleGeometry.data() );
}

if ( mRenderer )
mRenderer->stopRender( ctx );

return mLabels;
}

Expand Down
3 changes: 1 addition & 2 deletions src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ QgsSymbolV2* QgsCategorizedSymbolRendererV2::originalSymbolForFeature( QgsFeatur
QVariant value;
if ( mAttrNum == -1 )
{
if ( !mExpression.data() )
return 0;
Q_ASSERT( mExpression.data() );

value = mExpression->evaluate( &context.expressionContext() );
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgslabelingenginev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void TestQgsLabelingEngineV2::testBasic()

vl->setCustomProperty( "labeling/enabled", false );

QVERIFY( imageCheck( "labeling_basic_loop", img2, 0 ) );
QVERIFY( imageCheck( "labeling_basic", img2, 0 ) );
}


Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.

0 comments on commit f145843

Please sign in to comment.