[vlc-devel] [PATCH 3/6] qt: qrand is deprecated since Qt 5.15
Pierre Lamot
pierre at videolabs.io
Thu May 28 14:41:54 CEST 2020
---
modules/gui/qt/widgets/native/interface_widgets.cpp | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt/widgets/native/interface_widgets.cpp b/modules/gui/qt/widgets/native/interface_widgets.cpp
index 7e40bcea5f..b80c82879c 100644
--- a/modules/gui/qt/widgets/native/interface_widgets.cpp
+++ b/modules/gui/qt/widgets/native/interface_widgets.cpp
@@ -46,6 +46,7 @@
#include <QSlider>
#include <QBitmap>
#include <QUrl>
+#include <QRandomGenerator>
#if defined (QT5_HAS_X11)
# include <X11/Xlib.h>
@@ -589,9 +590,11 @@ void EasterEggBackgroundWidget::spawnFlakes()
{
if ( ! isVisible() ) return;
- double w = (double) width() / RAND_MAX;
+ QRandomGenerator* rg = QRandomGenerator::global();
- int i_spawn = ( (double) qrand() / RAND_MAX ) * i_rate;
+ double w = (double) width();
+
+ int i_spawn = rg->generateDouble() * i_rate;
auto it = flakes->begin();
while( it != flakes->end() )
@@ -611,8 +614,8 @@ void EasterEggBackgroundWidget::spawnFlakes()
for ( int i=0; i<i_spawn; i++ )
{
flake *f = new flake;
- f->point.setX( qrand() * w );
- f->b_fat = ( qrand() < ( RAND_MAX * .33 ) );
+ f->point.setX( rg->generateDouble() * w );
+ f->b_fat = ( rg->generateDouble() < .33 );
flakes->push_back( f );
}
update();
--
2.25.1
More information about the vlc-devel
mailing list