From 09075656ccd37362e34efb44be9447086bba552e Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 19 Nov 2020 13:07:17 +0100 Subject: [PATCH] replace deprecated qrand --- GUI/coregui/Views/SampleDesigner/DesignerHelper.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GUI/coregui/Views/SampleDesigner/DesignerHelper.cpp b/GUI/coregui/Views/SampleDesigner/DesignerHelper.cpp index 3a71960ef83..f0d23adbafe 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerHelper.cpp +++ b/GUI/coregui/Views/SampleDesigner/DesignerHelper.cpp @@ -15,9 +15,9 @@ #include "GUI/coregui/Views/SampleDesigner/DesignerHelper.h" #include "GUI/coregui/utils/StyleUtils.h" #include <QPainter> -#include <QtGlobal> #include <cmath> #include <iostream> +#include <random> namespace { @@ -131,7 +131,11 @@ QPixmap DesignerHelper::getPixmapParticle() QColor DesignerHelper::getRandomColor() { - return QColor(qrand() % 256, qrand() % 256, qrand() % 256); + static std::random_device r; + std::default_random_engine re(r()); + std::uniform_int_distribution<int> ru(0, 255); + + return QColor(ru(re), ru(re), ru(re)); } bool DesignerHelper::sort_layers(QGraphicsItem* left, QGraphicsItem* right) @@ -266,7 +270,7 @@ QRectF DesignerHelper::getTransformationBoundingRect() QColor DesignerHelper::getDefaultMaterialColor() { - return QColor(qrand() % 256, qrand() % 256, qrand() % 256); + return getRandomColor(); } int DesignerHelper::getSectionFontSize() -- GitLab