diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-04-08 00:20:49 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-04-11 15:39:37 +0000 |
commit | 594175be357562561f04f5be83a68f2c6c8165c2 (patch) | |
tree | 53ac1f7103940fe8919cc4b16bf6a1d689178800 /src/location/maps | |
parent | 07eeb77c793caaeb49ae29043f2ca4ee0c2cce7a (diff) |
Prevent accessing invalid QGeoTileSpec from QHash look-ups
Change-Id: Ic169824201ed6aeaeb2a482b28da989f9312181d
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/maps')
-rw-r--r-- | src/location/maps/qgeotiledmapscene.cpp | 22 |
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())); } |