Skip to content
Permalink
Browse files

only call data once in drawLayerTitleInternal

  • Loading branch information
roya0045 authored and nyalldawson committed Feb 13, 2020
1 parent 9ce12c0 commit 740c08be5d4b964b9b9968a8258d253fb678e67d
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/core/qgslegendrenderer.cpp
@@ -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;
@@ -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 )

0 comments on commit 740c08b

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