Skip to content

Commit

Permalink
only call data once in drawLayerTitleInternal
Browse files Browse the repository at this point in the history
  • Loading branch information
roya0045 authored and nyalldawson committed Feb 13, 2020
1 parent 9ce12c0 commit 740c08b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/qgslegendrenderer.cpp
Expand Up @@ -684,9 +684,9 @@ QSizeF QgsLegendRenderer::drawLayerTitleInternal( QgsLayerTreeLayer *nodeLayer,
{
QSizeF size( 0, 0 );
QModelIndex idx = mLegendModel->node2index( nodeLayer );

QString titleString = mLegendModel->data( idx, Qt::DisplayRole ).toString();
//Let the user omit the layer title item by having an empty layer title string
if ( mLegendModel->data( idx, Qt::DisplayRole ).toString().isEmpty() )
if ( titleString.isEmpty() )
return size;

double y = top;
Expand All @@ -707,7 +707,7 @@ QSizeF QgsLegendRenderer::drawLayerTitleInternal( QgsLayerTreeLayer *nodeLayer,

QgsExpressionContext tempContext;

const QStringList lines = mSettings.evaluateItemText( mLegendModel->data( idx, Qt::DisplayRole ).toString(),
const QStringList lines = mSettings.evaluateItemText( titleString,
context ? context->expressionContext() : tempContext );
int i = 0;
for ( QStringList::ConstIterator layerItemPart = lines.constBegin(); layerItemPart != lines.constEnd(); ++layerItemPart )
Expand Down

0 comments on commit 740c08b

Please sign in to comment.