kylin-music/0001-use-QRandomGenerator-to-generate-random-numbers.patch
侯红勋 d77fc1537b use QRandomGenerator to generate random numbers
Signed-off-by: 侯红勋 <houhongxun@kylinos.cn>
2024-05-06 10:14:28 +08:00

43 lines
1.3 KiB
Diff

From 64e868be8ff42979c955a38b34678b9e24a18dcf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BE=AF=E7=BA=A2=E5=8B=8B?= <houhongxun@kylinos.cn>
Date: Mon, 6 May 2024 10:00:18 +0800
Subject: [PATCH] use QRandomGenerator to generate random numbers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 侯红勋 <houhongxun@kylinos.cn>
---
UIControl/player/coreplayer/mmediaplaylist.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/UIControl/player/coreplayer/mmediaplaylist.cpp b/UIControl/player/coreplayer/mmediaplaylist.cpp
index 9aa1c03..38f93a5 100644
--- a/UIControl/player/coreplayer/mmediaplaylist.cpp
+++ b/UIControl/player/coreplayer/mmediaplaylist.cpp
@@ -16,6 +16,7 @@
*/
#include "mmediaplaylist.h"
+#include <QRandomGenerator>
MMediaPlaylist::MMediaPlaylist(QObject *parent)
: QObject(parent)
@@ -223,11 +224,10 @@ MMediaPlaylist::PlaybackMode MMediaPlaylist::playbackMode() const
int MMediaPlaylist::randomIndex()
{
- qsrand(QDateTime::currentDateTime().toMSecsSinceEpoch());
- return qrand()%(m_playerList.length());
+ QRandomGenerator rnd(QDateTime::currentDateTime().toMSecsSinceEpoch());
+ return rnd.generate()%(m_playerList.length());
}
-
MMediaContent::MMediaContent(QUrl url)
{
m_url = url;
--
2.43.0