Skip to content

Commit

Permalink
Fix possible nullptr dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 29, 2022
1 parent 0803809 commit d76a80d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/layertree/qgslayertreemodellegendnode.cpp
Expand Up @@ -198,7 +198,7 @@ QSizeF QgsLayerTreeModelLegendNode::drawSymbolText( const QgsLegendSettings &set

// TODO QGIS 4.0 -- make these all mandatory
std::optional< QgsTextDocument > tempDocument;
const QgsTextDocument *document = ctx->textDocument;
const QgsTextDocument *document = ctx ? ctx->textDocument : nullptr;
if ( !document )
{
const QStringList lines = settings.evaluateItemText( data( Qt::DisplayRole ).toString(), context->expressionContext() );
Expand All @@ -207,7 +207,7 @@ QSizeF QgsLayerTreeModelLegendNode::drawSymbolText( const QgsLegendSettings &set
}

std::optional< QgsTextDocumentMetrics > tempMetrics;
const QgsTextDocumentMetrics *metrics = ctx->textDocumentMetrics;
const QgsTextDocumentMetrics *metrics = ctx ? ctx->textDocumentMetrics : nullptr;
if ( !metrics )
{
tempMetrics.emplace( QgsTextDocumentMetrics::calculateMetrics( *document, format, *context ) );
Expand Down

0 comments on commit d76a80d

Please sign in to comment.