aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2017-01-22 17:25:17 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2017-01-23 15:44:26 +0000
commit5c2ba6db53b2190160081695faff521bc367e33d (patch)
tree116b0b9eee4151d8272719280141f0cfbb0ab949
parent364de6e01c88cef1ec2f1a6d13dc8d356e159ad0 (diff)
Destroy the async PathItem work pool properly
Avoid getting warnings from QWaitCondition on Windows by managing the lifetime of the QThreadPool ourselves. Change-Id: Idc3545a2336f7971bd382560aa958a325ac69fc6 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r--src/quick/items/qquickpathitemgenericrenderer.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/quick/items/qquickpathitemgenericrenderer.cpp b/src/quick/items/qquickpathitemgenericrenderer.cpp
index bf9506ba65..3de01a5bc7 100644
--- a/src/quick/items/qquickpathitemgenericrenderer.cpp
+++ b/src/quick/items/qquickpathitemgenericrenderer.cpp
@@ -270,6 +270,14 @@ void QQuickPathItemGenericRenderer::setAsyncCallback(void (*callback)(void *), v
m_asyncCallbackData = data;
}
+static QThreadPool *pathWorkThreadPool = nullptr;
+
+static void deletePathWorkThreadPool()
+{
+ delete pathWorkThreadPool;
+ pathWorkThreadPool = nullptr;
+}
+
void QQuickPathItemGenericRenderer::endSync(bool async)
{
bool didKickOffAsync = false;
@@ -295,13 +303,11 @@ void QQuickPathItemGenericRenderer::endSync(bool async)
continue;
}
- static QThreadPool threadPool;
- static bool threadPoolReady = false;
-
- if (async && !threadPoolReady) {
- threadPoolReady = true;
+ if (async && !pathWorkThreadPool) {
+ qAddPostRoutine(deletePathWorkThreadPool);
+ pathWorkThreadPool = new QThreadPool;
const int idealCount = QThread::idealThreadCount();
- threadPool.setMaxThreadCount(idealCount > 0 ? idealCount * 2 : 4);
+ pathWorkThreadPool->setMaxThreadCount(idealCount > 0 ? idealCount * 2 : 4);
}
if ((d.syncDirty & DirtyFillGeom) && d.fillColor.a) {
@@ -334,7 +340,7 @@ void QQuickPathItemGenericRenderer::endSync(bool async)
r->deleteLater();
});
didKickOffAsync = true;
- threadPool.start(r);
+ pathWorkThreadPool->start(r);
} else {
triangulateFill(d.path, d.fillColor, &d.fillVertices, &d.fillIndices, &d.indexType, q_supportsElementIndexUint(m_api));
}
@@ -362,7 +368,7 @@ void QQuickPathItemGenericRenderer::endSync(bool async)
r->deleteLater();
});
didKickOffAsync = true;
- threadPool.start(r);
+ pathWorkThreadPool->start(r);
} else {
triangulateStroke(d.path, d.pen, d.strokeColor, &d.strokeVertices,
QSize(m_item->width(), m_item->height()));