summaryrefslogtreecommitdiffstats
path: root/examples/corelib/threads/queuedcustomtype/renderthread.cpp
diff options
context:
space:
mode:
authorRym Bouabid <rym.bouabid@qt.io>2023-09-20 18:12:29 +0200
committerRym Bouabid <rym.bouabid@qt.io>2023-10-02 19:08:42 +0200
commit34ff72d0ba5284ff117ee4ae7f04072b51c85315 (patch)
tree563e9742c1b9fa3fc533901f0a1b8477ebfd149e /examples/corelib/threads/queuedcustomtype/renderthread.cpp
parentaa9529408041ab16bb920840d78b3f41c759a2f8 (diff)
Revamp Queued Custom Type Ex: Add const when applicable
Task-number: QTBUG-117147 Pick-to: 6.6 6.5 Change-Id: I2fe342fa585f8c1203fa64d2a9ceabc07070cc77 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'examples/corelib/threads/queuedcustomtype/renderthread.cpp')
-rw-r--r--examples/corelib/threads/queuedcustomtype/renderthread.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/corelib/threads/queuedcustomtype/renderthread.cpp b/examples/corelib/threads/queuedcustomtype/renderthread.cpp
index deb518e2b1..5a65f4ca76 100644
--- a/examples/corelib/threads/queuedcustomtype/renderthread.cpp
+++ b/examples/corelib/threads/queuedcustomtype/renderthread.cpp
@@ -35,21 +35,21 @@ void RenderThread::processImage(const QImage &image)
void RenderThread::run()
{
- int size = qMax(m_image.width()/20, m_image.height()/20);
+ const int size = qMax(m_image.width()/20, m_image.height()/20);
for (int s = size; s > 0; --s) {
for (int c = 0; c < 400; ++c) {
//![processing the image (start)]
- int x1 = qMax(0, QRandomGenerator::global()->bounded(m_image.width()) - s/2);
- int x2 = qMin(x1 + s/2 + 1, m_image.width());
- int y1 = qMax(0, QRandomGenerator::global()->bounded(m_image.height()) - s/2);
- int y2 = qMin(y1 + s/2 + 1, m_image.height());
+ const int x1 = qMax(0, QRandomGenerator::global()->bounded(m_image.width()) - s/2);
+ const int x2 = qMin(x1 + s/2 + 1, m_image.width());
+ const int y1 = qMax(0, QRandomGenerator::global()->bounded(m_image.height()) - s/2);
+ const int y2 = qMin(y1 + s/2 + 1, m_image.height());
int n = 0;
int red = 0;
int green = 0;
int blue = 0;
for (int i = y1; i < y2; ++i) {
for (int j = x1; j < x2; ++j) {
- QRgb pixel = m_image.pixel(j, i);
+ const QRgb pixel = m_image.pixel(j, i);
red += qRed(pixel);
green += qGreen(pixel);
blue += qBlue(pixel);
@@ -57,7 +57,7 @@ void RenderThread::run()
}
}
//![processing the image (finish)]
- Block block(QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1),
+ 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)