forked from qt-creator/qt-creator
Replace qrand with QRandomGenerator
Task-number: QTCREATORBUG-24098 Change-Id: I91b610409a413c7d76b3c5dd43cf581a960edf7d Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -645,7 +645,7 @@ static QString getUserFilePath(const QString &proposalFileName)
|
||||
if (++count > 15)
|
||||
return QString();
|
||||
// add random number
|
||||
const int number = QRandomGenerator().generate() % 1000;
|
||||
const int number = QRandomGenerator::global()->generate() % 1000;
|
||||
tryPath = newFilePath + QString::number(number) + suffix;
|
||||
}
|
||||
return tryPath;
|
||||
|
@@ -56,8 +56,9 @@
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
#include <QApplication>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
@@ -420,8 +421,10 @@ static void scatterItem(const ModelNode &pastedNode, const ModelNode &targetNode
|
||||
double y = pastedNode.variantProperty("y").value().toDouble();
|
||||
double targetWidth = 20;
|
||||
double targetHeight = 20;
|
||||
x = x + double(qrand()) / RAND_MAX * targetWidth - targetWidth / 2;
|
||||
y = y + double(qrand()) / RAND_MAX * targetHeight - targetHeight / 2;
|
||||
x = x + double(QRandomGenerator::global()->generate()) / RAND_MAX * targetWidth
|
||||
- targetWidth / 2;
|
||||
y = y + double(QRandomGenerator::global()->generate()) / RAND_MAX * targetHeight
|
||||
- targetHeight / 2;
|
||||
pastedNode.variantProperty("x").setValue(int(x));
|
||||
pastedNode.variantProperty("y").setValue(int(y));
|
||||
} else {
|
||||
@@ -489,7 +492,7 @@ void DesignDocument::paste()
|
||||
rewriterView()->executeInTransaction("DesignDocument::paste1", [&view, selectedNodes, targetNode](){
|
||||
QList<ModelNode> pastedNodeList;
|
||||
|
||||
int offset = double(qrand()) / RAND_MAX * 20 - 10;
|
||||
int offset = double(QRandomGenerator::global()->generate()) / RAND_MAX * 20 - 10;
|
||||
|
||||
foreach (const ModelNode &node, selectedNodes) {
|
||||
PropertyName defaultProperty(targetNode.metaInfo().defaultPropertyName());
|
||||
|
@@ -37,8 +37,9 @@
|
||||
#include "stateitem.h"
|
||||
#include "transitionitem.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGuiApplication>
|
||||
#include <QRandomGenerator>
|
||||
#include <QtMath>
|
||||
|
||||
namespace ScxmlEditor {
|
||||
@@ -236,7 +237,7 @@ void layout(const QList<QGraphicsItem*> &items)
|
||||
if (finalItem && finalItem->inputTransitionCount() > 0)
|
||||
lastItem = finalItem->inputTransitions().constFirst()->connectedItem(finalItem);
|
||||
|
||||
int startAngle = qrand() % 2 == 0 ? 180 : 90;
|
||||
int startAngle = QRandomGenerator::global()->generate() % 2 == 0 ? 180 : 90;
|
||||
int startDistance = 40 + childItems.count() * 10;
|
||||
if (!childItems.isEmpty()) {
|
||||
// Init position of the items
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -27,12 +27,12 @@
|
||||
#include "outputgenerator.h"
|
||||
|
||||
#include <QAbstractSocket>
|
||||
#include <QIODevice>
|
||||
#include <QTextStream>
|
||||
#include <QCoreApplication>
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QIODevice>
|
||||
#include <QRandomGenerator>
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
|
||||
// Yes, this is ugly. But please don't introduce a libUtils dependency
|
||||
// just to get rid of a single function.
|
||||
@@ -123,14 +123,14 @@ void OutputGenerator::produceRuntimeError()
|
||||
|
||||
void OutputGenerator::writeOutput()
|
||||
{
|
||||
m_timer.setInterval(qrand() % 1000);
|
||||
m_timer.setInterval(QRandomGenerator::global()->generate() % 1000);
|
||||
|
||||
int lines = 0;
|
||||
while (!m_input->atEnd()) {
|
||||
qint64 lastPos = m_input->pos();
|
||||
QByteArray line = m_input->readLine();
|
||||
if (lines > 0 && !m_finished && line.contains("<error>")) {
|
||||
if ((m_crash || m_garbage || m_wait) && qrand() % 10 == 1) {
|
||||
if ((m_crash || m_garbage || m_wait) && QRandomGenerator::global()->generate() % 10 == 1) {
|
||||
produceRuntimeError();
|
||||
m_timer.start();
|
||||
return;
|
||||
|
Reference in New Issue
Block a user