fix deprecated warning qsrand

This function is obsolete.

Use QRandomGenerator instead.
This class was introduced in Qt 5.10.
This commit is contained in:
Simon De Backer
2020-06-10 19:49:27 +02:00
committed by Laurent Trinques
parent 5d2d4a48a5
commit 2570108caf

View File

@@ -25,6 +25,7 @@
#include <QtCore/QDateTime>
#include <QtCore/QByteArray>
#include <QtCore/QSharedMemory>
#include <QRandomGenerator>
#include "singleapplication.h"
#include "singleapplication_p.h"
@@ -99,8 +100,13 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
d->memory->unlock();
// Random sleep here limits the probability of a collision between two racing apps
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) // ### Qt 6: remove
qsrand( QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max() );
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( qrand() ) / RAND_MAX * 10 ) );
#else
quint32 value = QRandomGenerator::global()->generate();
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( value ) / RAND_MAX * 10 ) );
#endif
}
if( inst->primary == false) {