Replace qrand with QRandomGenerator when using Qt 5.10 or higher

This commit is contained in:
Jonas Kvinge
2020-05-29 17:37:46 +02:00
parent 6c77294a86
commit 5d5723ad58
8 changed files with 63 additions and 16 deletions

View File

@@ -48,6 +48,9 @@
#include <QTcpSocket>
#include <QSslSocket>
#include <QDateTime>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
# include <QRandomGenerator>
#endif
LocalRedirectServer::LocalRedirectServer(QObject *parent)
: QTcpServer(parent),
@@ -152,7 +155,12 @@ bool LocalRedirectServer::GenerateCertificate() {
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
quint64 serial = 9999999 + QRandomGenerator::global()->bounded(1000000);
#else
quint64 serial = (9999999 + qrand() % 1000000);
#endif
QByteArray q_serial;
q_serial.setNum(serial);