From bd5c6fab403fd8d79b84aaf05424a24e2c88709d Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 23 Oct 2023 13:41:46 +0200 Subject: QueuedCustomType example: use QThread::requestInterruption Drop the home-made solution with mutex and bool (which could have been an atomic, but we have had a ready-made solution in QThread for a long time). Pick-to: 6.5 6.6 Change-Id: Id213a021f0ae94215afb28ff874fcb597dd1e6f9 Reviewed-by: MohammadHossein Qanbari Reviewed-by: Edward Welbourne Reviewed-by: Mikko Hallamaa Reviewed-by: Ed Cooke --- .../corelib/threads/queuedcustomtype/renderthread.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'examples/corelib/threads/queuedcustomtype/renderthread.cpp') diff --git a/examples/corelib/threads/queuedcustomtype/renderthread.cpp b/examples/corelib/threads/queuedcustomtype/renderthread.cpp index 5a65f4ca76..34a439f3fe 100644 --- a/examples/corelib/threads/queuedcustomtype/renderthread.cpp +++ b/examples/corelib/threads/queuedcustomtype/renderthread.cpp @@ -10,15 +10,10 @@ RenderThread::RenderThread(QObject *parent) : QThread(parent) { - m_abort = false; } RenderThread::~RenderThread() { - mutex.lock(); - m_abort = true; - mutex.unlock(); - wait(); } @@ -29,7 +24,6 @@ void RenderThread::processImage(const QImage &image) return; m_image = image; - m_abort = false; start(); } @@ -60,17 +54,10 @@ void RenderThread::run() const Block block(QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1), QColor(red/n, green/n, blue/n)); emit sendBlock(block); - if (m_abort) + if (isInterruptionRequested()) return; msleep(10); } } } //![processing the image (finish)] - -void RenderThread::stopProcess() -{ - mutex.lock(); - m_abort = true; - mutex.unlock(); -} -- cgit v1.2.3