Skip to content
Permalink
Browse files
Fix several dangling references in grid decoration
The functions in question all return values, not references, so we need
to store those values somwhere.
  • Loading branch information
joto authored and nyalldawson committed Oct 22, 2021
1 parent a4c61f0 commit 93225b0984bc220930897941530e357b0a84f70a
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/app/decorations/qgsdecorationgrid.cpp
@@ -451,9 +451,9 @@ int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList< QPa
if ( mGridIntervalY / mapSettings.mapUnitsPerPixel() < 1 )
return 1;

const QPolygonF &canvasPoly = canvasPolygon( mapSettings );
const QPolygonF &mapPolygon = canvasExtent( mapSettings );
const QRectF &mapBoundingRect = mapPolygon.boundingRect();
const QPolygonF canvasPoly = canvasPolygon( mapSettings );
const QPolygonF mapPolygon = canvasExtent( mapSettings );
const QRectF mapBoundingRect = mapPolygon.boundingRect();
const QLineF lineEast( mapPolygon[2], mapPolygon[1] );
const QLineF lineWest( mapPolygon[3], mapPolygon[0] );

@@ -496,15 +496,15 @@ int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList< QPa
if ( mGridIntervalX / mapSettings.mapUnitsPerPixel() < 1 )
return 1;

const QPolygonF &canvasPoly = canvasPolygon( mapSettings );
const QPolygonF &mapPolygon = canvasExtent( mapSettings );
const QPolygonF canvasPoly = canvasPolygon( mapSettings );
const QPolygonF mapPolygon = canvasExtent( mapSettings );
const QLineF lineSouth( mapPolygon[3], mapPolygon[2] );
const QLineF lineNorth( mapPolygon[0], mapPolygon[1] );

const double len = lineSouth.length();
Q_ASSERT( std::fabs( len - lineNorth.length() ) < 1e-6 ); // no shear

const QRectF &mapBoundingRect = mapPolygon.boundingRect();
const QRectF mapBoundingRect = mapPolygon.boundingRect();
const double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
double dist = static_cast< int >( ( mapBoundingRect.left() - mGridOffsetX ) / mGridIntervalX + roundCorrection ) * mGridIntervalX + mGridOffsetX;
dist = dist - mapBoundingRect.left();

0 comments on commit 93225b0

Please sign in to comment.