From 67820d7c4dfa963c5c4bf2ae19351f5d0654d850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 22 Nov 2024 21:52:32 +0100 Subject: [PATCH] Do not try to draw labels outside the tile rect --- src/map/ENC/rastertile.cpp | 9 +++++++-- src/map/IMG/rastertile.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/map/ENC/rastertile.cpp b/src/map/ENC/rastertile.cpp index 8558d37c..dcba0978 100644 --- a/src/map/ENC/rastertile.cpp +++ b/src/map/ENC/rastertile.cpp @@ -220,8 +220,13 @@ void RasterTile::drawLines(QPainter *painter, const QList &lines) void RasterTile::drawTextItems(QPainter *painter, const QList &textItems) { - for (int i = 0; i < textItems.size(); i++) - textItems.at(i)->paint(painter); + QRectF rect(_rect); + + for (int i = 0; i < textItems.size(); i++) { + const TextItem *ti = textItems.at(i); + if (rect.intersects(ti->boundingRect())) + ti->paint(painter); + } } void RasterTile::processPolygons(const QList &polygons, diff --git a/src/map/IMG/rastertile.cpp b/src/map/IMG/rastertile.cpp index 634aaea1..7425cada 100644 --- a/src/map/IMG/rastertile.cpp +++ b/src/map/IMG/rastertile.cpp @@ -217,8 +217,13 @@ void RasterTile::drawLines(QPainter *painter, void RasterTile::drawTextItems(QPainter *painter, const QList &textItems) const { - for (int i = 0; i < textItems.size(); i++) - textItems.at(i)->paint(painter); + QRectF rect(_rect); + + for (int i = 0; i < textItems.size(); i++) { + const TextItem *ti = textItems.at(i); + if (rect.intersects(ti->boundingRect())) + ti->paint(painter); + } } static void removeDuplicitLabel(QList &labels, const QString &text,