Commit ad88d17d authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to QRandomGenerator

parent cb93a958
......@@ -36,6 +36,7 @@
#include <QByteArray>
#include <QString>
#include <QTimeZone>
#include <QRandomGenerator>
#include "davresource_debug.h"
......@@ -44,7 +45,7 @@ typedef QSharedPointer<KCalendarCore::Incidence> IncidencePtr;
static QString createUniqueId()
{
const qint64 time = QDateTime::currentMSecsSinceEpoch() / 1000;
const int r = qrand() % 1000;
const int r = QRandomGenerator::global()->bounded(1000);
const QString id = QLatin1Char('R') + QString::number(r);
const QString uid = QString::number(time) + QLatin1Char('.') + id;
return uid;
......
......@@ -26,6 +26,7 @@
#include <QHostInfo>
#include <QUuid>
#include <QRegularExpression>
#include <QRandomGenerator>
#include "libmaildir_debug.h"
#include <KLocalizedString>
......@@ -549,7 +550,7 @@ QByteArray Maildir::readEntryHeaders(const QString &key) const
static QString createUniqueFileName()
{
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const int r = qrand() % 1000;
const int r = QRandomGenerator::global()->bounded(1000);
const QString identifier = QLatin1String("R") + QString::number(r);
QString fileName = QString::number(time) + QLatin1Char('.') + identifier + QLatin1Char('.');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment