diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-01-22 16:48:15 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-01-23 13:56:26 +0000 |
commit | a2252ba7b3942bbafbbb8f4db144f2cfbf0787ab (patch) | |
tree | 5c34aa9d9fb1bb963d9098ec6d71eeb2924ddd79 | |
parent | 77614c6c48ce8caf5697afb53a26caf1b165fed3 (diff) |
Fix case when async PathItem goes down before finish
Marking the work orphaned (to be ignored) is sufficient since
runnables exist independently of the renderer or item instances.
(even if the lambda executes after the entire Quick infra is gone,
we are still fine, as long as we bail out in time and do not
dereference the captured this)
Change-Id: I0cfb09aaa8b363191ff576b17a88bb7c1c38f3ad
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r-- | src/quick/items/qquickpathitemgenericrenderer.cpp | 12 | ||||
-rw-r--r-- | src/quick/items/qquickpathitemgenericrenderer_p.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/quick/items/qquickpathitemgenericrenderer.cpp b/src/quick/items/qquickpathitemgenericrenderer.cpp index 367fac985e..e36654ad0c 100644 --- a/src/quick/items/qquickpathitemgenericrenderer.cpp +++ b/src/quick/items/qquickpathitemgenericrenderer.cpp @@ -104,6 +104,16 @@ void QQuickPathItemGenericStrokeFillNode::activateMaterial(Material m) setMaterial(m_material); } +QQuickPathItemGenericRenderer::~QQuickPathItemGenericRenderer() +{ + for (VisualPathData &d : m_vp) { + if (d.pendingFill) + d.pendingFill->orphaned = true; + if (d.pendingStroke) + d.pendingStroke->orphaned = true; + } +} + // sync, and so triangulation too, happens on the gui thread // - except when async is set, in which case triangulation is moved to worker threads @@ -263,6 +273,8 @@ void QQuickPathItemGenericRenderer::endSync(bool async) // Unlikely in practice but in theory m_vp could be // resized. Therefore, capture 'i' instead of 'd'. QObject::connect(r, &QQuickPathItemFillRunnable::done, qApp, [this, i](QQuickPathItemFillRunnable *r) { + // Bail out when orphaned (meaning either another run was + // started after this one, or the renderer got destroyed). if (!r->orphaned && i < m_vp.count()) { VisualPathData &d(m_vp[i]); d.fillVertices = r->fillVertices; diff --git a/src/quick/items/qquickpathitemgenericrenderer_p.h b/src/quick/items/qquickpathitemgenericrenderer_p.h index 17c1f73310..ca05492841 100644 --- a/src/quick/items/qquickpathitemgenericrenderer_p.h +++ b/src/quick/items/qquickpathitemgenericrenderer_p.h @@ -81,6 +81,7 @@ public: m_accDirty(0), m_asyncCallback(nullptr) { } + ~QQuickPathItemGenericRenderer(); void beginSync(int totalCount) override; void setPath(int index, const QQuickPath *path) override; |