From 5c2ba6db53b2190160081695faff521bc367e33d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sun, 22 Jan 2017 17:25:17 +0100 Subject: 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 --- src/quick/items/qquickpathitemgenericrenderer.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/quick') 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())); -- cgit v1.2.3