From e701ad0ed0f2f5162b32ff37fa7570cbe8cc0be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Wed, 25 May 2022 23:04:20 +0200 Subject: [PATCH] Fixed broken PDF/PNG export of MApsforge maps --- src/map/mapsforgemap.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/map/mapsforgemap.cpp b/src/map/mapsforgemap.cpp index 947e94ea..c97e4a83 100644 --- a/src/map/mapsforgemap.cpp +++ b/src/map/mapsforgemap.cpp @@ -164,8 +164,6 @@ void MapsforgeMap::cancelJobs() void MapsforgeMap::draw(QPainter *painter, const QRectF &rect, Flags flags) { - Q_UNUSED(flags); - QPointF tl(floor(rect.left() / _data.tileSize()) * _data.tileSize(), floor(rect.top() / _data.tileSize()) * _data.tileSize()); QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); @@ -215,8 +213,20 @@ void MapsforgeMap::draw(QPainter *painter, const QRectF &rect, Flags flags) } } - if (!tiles.isEmpty()) - runJob(new MapsforgeMapJob(tiles)); + if (!tiles.isEmpty()) { + if (flags & Map::Block) { + QFuture future = QtConcurrent::map(tiles, &RasterTile::render); + future.waitForFinished(); + + for (int i = 0; i < tiles.size(); i++) { + const RasterTile &mt = tiles.at(i); + const QPixmap &pm = mt.pixmap(); + painter->drawPixmap(mt.xy(), pm); + QPixmapCache::insert(key(mt.zoom(), mt.xy()), pm); + } + } else + runJob(new MapsforgeMapJob(tiles)); + } } void MapsforgeMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)