diff --git a/0001-use-QRandomGenerator-and-fix-code-error.patch b/0001-use-QRandomGenerator-and-fix-code-error.patch new file mode 100644 index 0000000..7503940 --- /dev/null +++ b/0001-use-QRandomGenerator-and-fix-code-error.patch @@ -0,0 +1,41 @@ +From 8a2239a0376826739d4fa1066d483a531d5c407a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E4=BE=AF=E7=BA=A2=E5=8B=8B?= +Date: Mon, 6 May 2024 14:10:34 +0800 +Subject: [PATCH] use QRandomGenerator, and fix code error +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: 侯红勋 +--- + model/dataparser.cpp | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/model/dataparser.cpp b/model/dataparser.cpp +index 3719334..a733b29 100644 +--- a/model/dataparser.cpp ++++ b/model/dataparser.cpp +@@ -1,5 +1,5 @@ + #include "dataparser.h" +- ++#include + DataParser::DataParser() {} + + //处理返回的网络数据 +@@ -309,10 +309,11 @@ void DataParser::hourlyWeather(QJsonObject hourlyObj, QList hourlist) + void DataParser::tmphourlyWeather(QJsonObject hourlyObj, QList hourlist) + { + QTime current_time = QTime::currentTime(); ++ QRandomGenerator rnd(current_time.msecsSinceStartOfDay()); + int hour = current_time.hour() + 1; //当前的小时 + for (int i = 0; i < 24; i++) { +- int num_code = qrand() % (1, 60); +- int num_tmp = qrand() % (-10, 30); ++ int num_code = rnd.bounded(0, 61); ++ int num_tmp = rnd.bounded(-10, 31); + QString tmpText = QString::number(num_tmp) + "°C"; + Hourly tmp_hour; + QString hour_tmp = QString::number(hour + i) + ":00"; +-- +2.43.0 + diff --git a/kylin-weather.spec b/kylin-weather.spec index 41ae103..838d112 100644 --- a/kylin-weather.spec +++ b/kylin-weather.spec @@ -1,12 +1,13 @@ Name: kylin-weather Version: 3.1.2 -Release: 3 +Release: 4 Summary: Indicator that displays China weather information License: GPL-3.0+ URL: https://gitee.com/openkylin/kylin-weather Source0: %{name}-%{version}.tar.gz Patch01: 0001-fix-compile-error-of-kylin-weather.patch Patch02: 0001-fix-coredump-of-kylin-weather.patch +Patch03: 0001-use-QRandomGenerator-and-fix-code-error.patch BuildRequires: qt5-qtbase-devel BuildRequires: qtchooser @@ -28,8 +29,9 @@ change it. %prep %setup -q -%patch01 -p1 -%patch02 -p1 +%patch -p1 1 +%patch -p1 2 +%patch -p1 3 %build mkdir build && pushd build @@ -64,6 +66,10 @@ fi %{_datadir}/kylin-user-guide/* %changelog +* Mon May 06 2024 houhongxun - 3.1.2-4 +- use QRandomGenerator to generate random numbers +- fix some code errors + * Sat Nov 25 2023 hua_yadong - 3.1.2-3 - add 0001-fix-coredump-of-kylin-weather.patch