Replace qrand with QRandomGenerator

Task-number: QTCREATORBUG-24098
Change-Id: I91b610409a413c7d76b3c5dd43cf581a960edf7d
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2020-09-17 12:04:27 +02:00
parent 73dee5fea8
commit 3a602e8338
5 changed files with 22 additions and 16 deletions

View File

@@ -29,6 +29,7 @@
#include <QColor>
#include <QMap>
#include <QRandomGenerator>
#include <QString>
namespace Valgrind {
@@ -42,9 +43,10 @@ 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)qrand() / RAND_MAX * 359),
((qreal)qrand() / RAND_MAX * 255),
((qreal)qrand() / RAND_MAX * 127) + 128);
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);
colorCache[text] = color;
return color;
}