summaryrefslogtreecommitdiffstats
path: root/examples/corelib/threads/queuedcustomtype/renderthread.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-10-23 13:41:46 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-10-27 07:55:42 +0200
commitbd5c6fab403fd8d79b84aaf05424a24e2c88709d (patch)
tree05561d620d9db43d9432f14636b316085a9b86f3 /examples/corelib/threads/queuedcustomtype/renderthread.cpp
parentae39b1634556f82fe5d7505ed9b6ebb883d6f813 (diff)
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 <mohammad.qanbari@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mikko Hallamaa <mikko.hallamaa@qt.io> Reviewed-by: Ed Cooke
Diffstat (limited to 'examples/corelib/threads/queuedcustomtype/renderthread.cpp')
-rw-r--r--examples/corelib/threads/queuedcustomtype/renderthread.cpp15
1 files changed, 1 insertions, 14 deletions
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();
-}