summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-05-09 12:56:25 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-05-09 20:01:41 +0000
commit80812d1b8a63cb8aef9b4f0928c226f5c7f386c5 (patch)
tree12d8656ac0057aec6c9265a8b9d5866f1703a842
parentcad3ffc8c90f3c194d06e52c981cd54cdab509ec (diff)
downloadqtlocation-80812d1b8a63cb8aef9b4f0928c226f5c7f386c5.tar.gz
Fix crash in Map{Polyline,Polygon,Route}ObjectQsg
When these objects get added to a map but aren't immediately visible (meaning are outside the visible region entirely), their respective QSGNodes will be marked as blocked. However, this isn't handled gracefully in qsgbatchrenderer. Renderer::nodeWasAdded discards nodes that are blocked. Meaning that when they will become unblocked, the node will result in being unallocated. This patch makes sure that a node is not instantiated at all if it would result in a blocked node. Change-Id: I8e174ba1d317e1d0c4006d993ec558bdad8a5b39 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp10
-rw-r--r--src/location/labs/qsg/qmappolygonobjectqsg.cpp2
-rw-r--r--src/location/labs/qsg/qmappolylineobjectqsg.cpp2
3 files changed, 7 insertions, 7 deletions
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
index eab0f214..71a75041 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
@@ -681,16 +681,12 @@ void MapPolygonNode::update(const QColor &fillColor, const QColor &borderColor,
* tree. We can't just block the fill without blocking the border too, so
* we're a little conservative here (maybe at the expense of rendering
* accuracy) */
- if (fillShape->size() == 0) {
- if (borderShape->size() == 0) {
+ if (fillShape->size() == 0 && borderShape->size() == 0) {
setSubtreeBlocked(true);
return;
- } else {
- setSubtreeBlocked(false);
- }
- } else {
- setSubtreeBlocked(false);
}
+ setSubtreeBlocked(false);
+
QSGGeometry *fill = QSGGeometryNode::geometry();
fillShape->allocateAndFill(fill);
diff --git a/src/location/labs/qsg/qmappolygonobjectqsg.cpp b/src/location/labs/qsg/qmappolygonobjectqsg.cpp
index b9602a3a..239df177 100644
--- a/src/location/labs/qsg/qmappolygonobjectqsg.cpp
+++ b/src/location/labs/qsg/qmappolygonobjectqsg.cpp
@@ -85,6 +85,8 @@ QSGNode *QMapPolygonObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode,
bool created = false;
if (!node) {
+ if (!m_geometry.size() && !m_borderGeometry.size())
+ return nullptr;
node = new MapPolygonNode();
*visibleNode = static_cast<VisibleNode *>(node);
created = true;
diff --git a/src/location/labs/qsg/qmappolylineobjectqsg.cpp b/src/location/labs/qsg/qmappolylineobjectqsg.cpp
index 6b782c77..f4a1a288 100644
--- a/src/location/labs/qsg/qmappolylineobjectqsg.cpp
+++ b/src/location/labs/qsg/qmappolylineobjectqsg.cpp
@@ -107,6 +107,8 @@ QSGNode *QMapPolylineObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode,
bool created = false;
if (!node) {
+ if (!m_geometry.size()) // condition to block the subtree
+ return nullptr;
node = new MapPolylineNode();
*visibleNode = static_cast<VisibleNode *>(node);
created = true;