summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-04-08 00:20:49 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-04-11 15:39:37 +0000
commit594175be357562561f04f5be83a68f2c6c8165c2 (patch)
tree53ac1f7103940fe8919cc4b16bf6a1d689178800
parent07eeb77c793caaeb49ae29043f2ca4ee0c2cce7a (diff)
downloadqtlocation-594175be357562561f04f5be83a68f2c6c8165c2.tar.gz
Prevent accessing invalid QGeoTileSpec from QHash look-ups
Change-Id: Ic169824201ed6aeaeb2a482b28da989f9312181d Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/location/maps/qgeotiledmapscene.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/location/maps/qgeotiledmapscene.cpp b/src/location/maps/qgeotiledmapscene.cpp
index 7885290e..e9adc98a 100644
--- a/src/location/maps/qgeotiledmapscene.cpp
+++ b/src/location/maps/qgeotiledmapscene.cpp
@@ -241,16 +241,20 @@ bool QGeoTiledMapScenePrivate::buildGeometry(const QGeoTileSpec &spec, QSGImageN
imageNode->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
// Calculate the texture mapping, in case we are magnifying some lower ZL tile
- const QGeoTileSpec textureSpec = m_textures.value(spec)->spec;
- if (textureSpec.zoom() < spec.zoom()) {
- overzooming = true;
- // Currently only using lower ZL tiles for the overzoom.
- const int tilesPerTexture = 1 << (spec.zoom() - textureSpec.zoom());
- const int mappedSize = imageNode->texture()->textureSize().width() / tilesPerTexture;
- const int x = (spec.x() % tilesPerTexture) * mappedSize;
- const int y = (spec.y() % tilesPerTexture) * mappedSize;
- imageNode->setSourceRect(QRectF(x, y, mappedSize, mappedSize));
+ const auto it = m_textures.find(spec); // This should be always found, but apparently sometimes it isn't, possibly due to memory shortage
+ if (it != m_textures.end()) {
+ if (it.value()->spec.zoom() < spec.zoom()) {
+ // Currently only using lower ZL tiles for the overzoom.
+ const int tilesPerTexture = 1 << (spec.zoom() - it.value()->spec.zoom());
+ const int mappedSize = imageNode->texture()->textureSize().width() / tilesPerTexture;
+ const int x = (spec.x() % tilesPerTexture) * mappedSize;
+ const int y = (spec.y() % tilesPerTexture) * mappedSize;
+ imageNode->setSourceRect(QRectF(x, y, mappedSize, mappedSize));
+ } else {
+ imageNode->setSourceRect(QRectF(QPointF(0,0), imageNode->texture()->textureSize()));
+ }
} else {
+ qWarning() << "!! buildGeometry: tileSpec not present in m_textures !!";
imageNode->setSourceRect(QRectF(QPointF(0,0), imageNode->texture()->textureSize()));
}