Skip to content

Commit 1b4c8b6

Browse files
committed
Do not render grid annotation if the lines/markers would be extremely dense
Otherwise drawing of huge amount of lines/markers can lock GUI
1 parent 434574e commit 1b4c8b6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/app/qgsdecorationgrid.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,11 @@ int QgsDecorationGrid::xGridLines( QList< QPair< double, QLineF > >& lines, QPai
537537
QPolygonF mapPolygon = canvasExtent();
538538
QRectF mapBoundingRect = mapPolygon.boundingRect();
539539

540+
// draw nothing if the distance between grid lines would be less than 1px
541+
// otherwise the grid lines would completely cover the whole map
542+
if ( mapBoundingRect.width() / mGridIntervalX >= p->device()->width() )
543+
return 1;
544+
540545
//consider to round up to the next step in case the left boundary is > 0
541546
double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0;
542547
double currentLevel = ( int )(( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY;
@@ -606,6 +611,11 @@ int QgsDecorationGrid::yGridLines( QList< QPair< double, QLineF > >& lines, QPai
606611
QPolygonF mapPolygon = canvasExtent();
607612
QRectF mapBoundingRect = mapPolygon.boundingRect();
608613

614+
// draw nothing if the distance between grid lines would be less than 1px
615+
// otherwise the grid lines would completely cover the whole map
616+
if ( mapBoundingRect.height() / mGridIntervalY >= p->device()->height() )
617+
return 1;
618+
609619
//consider to round up to the next step in case the left boundary is > 0
610620
double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
611621
double currentLevel = ( int )(( mapBoundingRect.left() - mGridOffsetX ) / mGridIntervalX + roundCorrection ) * mGridIntervalX + mGridOffsetX;

0 commit comments

Comments
 (0)