[vlc-devel] [PATCH 3/6] qt: qrand is deprecated since Qt 5.15

Pierre Lamot pierre at videolabs.io
Thu May 28 18:07:30 CEST 2020


Actually EasterEggBackgroundWidget is no longer used, the whole code 
could be deleted.

On 2020-05-28 18:02, Alexandre Janniaux wrote:
> Hi,
> 
> Not that is matters a lot, but this could use <random>
> instead of QRandomGenerator.
> 
> Regards,
> --
> Alexandre Janniaux
> Videolabs
> 
> On Thu, May 28, 2020 at 02:41:54PM +0200, Pierre Lamot wrote:
>> ---
>>  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
>> 
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list