aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/valgrind
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2023-10-26 12:42:37 +0200
committerChristian Stenger <christian.stenger@qt.io>2023-10-26 12:37:54 +0000
commit6ee59b3d3f27b24cb8af42098627b241df06daee (patch)
tree5b59654da4a2772f5821ae3c5a78f830df5cec20 /src/plugins/valgrind
parent46c0e63a6f5d79072b0d8e34e463481c598b0cf4 (diff)
Valgrind: Fix QColor warning
The code for generating random colors nowadays results in HSL parameters out of range warnings. Fix the generation of random color values. Change-Id: I27dfb1c59ced8f6776e83679532b296b69c089a9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/valgrind')
-rw-r--r--src/plugins/valgrind/callgrindhelper.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/plugins/valgrind/callgrindhelper.cpp b/src/plugins/valgrind/callgrindhelper.cpp
index 62dd37b0723..18c25a201fe 100644
--- a/src/plugins/valgrind/callgrindhelper.cpp
+++ b/src/plugins/valgrind/callgrindhelper.cpp
@@ -20,10 +20,9 @@ QColor CallgrindHelper::colorForString(const QString &text)
return colorCache.value(text);
// Minimum lightness of 100 to be readable with black text.
- const QColor color = QColor::fromHsl(
- ((qreal) QRandomGenerator::global()->generate() / RAND_MAX * 359),
- ((qreal) QRandomGenerator::global()->generate() / RAND_MAX * 255),
- ((qreal) QRandomGenerator::global()->generate() / RAND_MAX * 127) + 128);
+ const QColor color = QColor::fromHsl(QRandomGenerator::global()->generate() % 360,
+ QRandomGenerator::global()->generate() % 256,
+ QRandomGenerator::global()->generate() % 128 + 128);
colorCache[text] = color;
return color;
}