Skip to content

Commit

Permalink
Fix several dangling references in grid decoration
Browse files Browse the repository at this point in the history
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 93225b0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/app/decorations/qgsdecorationgrid.cpp
Expand Up @@ -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] );

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 93225b0

Please sign in to comment.