Skip to content

Commit 22fe478

Browse files
committed
fix: change update mode types from int to quint64
1. Changed update mode related types from int/uint to quint64 for consistency with D-Bus interface 2. Added refreshUpdateItemsChecked() method to properly update item checked states when mode changes 3. Fixed debounce timer to use quint64 for CheckUpdateMode property changes 4. Updated all related method signatures and property types to match These changes were necessary because: 1. The D-Bus interface uses 64-bit unsigned integers for update modes 2. Using smaller types could cause data truncation and incorrect behavior 3. The refresh logic needed to be separated from status refresh for better maintainability 4. Ensures type safety across the entire update mode handling chain fix: 将更新模式类型从 int 改为 quint64 1. 将更新模式相关类型从 int/uint 改为 quint64 以保持与 D-Bus 接口一致 2. 添加 refreshUpdateItemsChecked() 方法以便在模式变更时正确更新项目选中 状态 3. 修复防抖定时器使用 quint64 处理 CheckUpdateMode 属性变更 4. 更新所有相关方法签名和属性类型以匹配 这些变更是必要的因为: 1. D-Bus 接口使用 64 位无符号整数表示更新模式 2. 使用较小类型可能导致数据截断和错误行为 3. 需要将刷新逻辑与状态刷新分离以提高可维护性 4. 确保整个更新模式处理链的类型安全 pms: Bug-313905
1 parent 22eed95 commit 22fe478

5 files changed

Lines changed: 29 additions & 20 deletions

File tree

src/common/dbus/updatedbusproxy.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ bool UpdateDBusProxy::autoClean()
166166
return qvariant_cast<bool>(m_managerInter->property("AutoClean"));
167167
}
168168

169-
uint UpdateDBusProxy::updateMode()
169+
quint64 UpdateDBusProxy::updateMode()
170170
{
171-
return qvariant_cast<uint>(m_managerInter->property("UpdateMode"));
171+
return qvariant_cast<quint64>(m_managerInter->property("UpdateMode"));
172172
}
173173

174-
void UpdateDBusProxy::setUpdateMode(qulonglong value)
174+
void UpdateDBusProxy::setUpdateMode(quint64 value)
175175
{
176176
m_managerInter->setProperty("UpdateMode", QVariant::fromValue(value));
177177
}
@@ -191,12 +191,12 @@ QString UpdateDBusProxy::hardwareId()
191191
return qvariant_cast<QString>(m_managerInter->property("HardwareId"));
192192
}
193193

194-
int UpdateDBusProxy::checkUpdateMode()
194+
quint64 UpdateDBusProxy::checkUpdateMode()
195195
{
196-
return qvariant_cast<int>(m_managerInter->property("CheckUpdateMode"));
196+
return qvariant_cast<quint64>(m_managerInter->property("CheckUpdateMode"));
197197
}
198198

199-
void UpdateDBusProxy::setCheckUpdateMode(int value)
199+
void UpdateDBusProxy::setCheckUpdateMode(quint64 value)
200200
{
201201
m_managerInter->setProperty("CheckUpdateMode", QVariant::fromValue(value));
202202
}

src/common/dbus/updatedbusproxy.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class UpdateDBusProxy : public QObject
5858
bool autoClean();
5959

6060
Q_PROPERTY(qulonglong UpdateMode READ updateMode WRITE setUpdateMode NOTIFY UpdateModeChanged)
61-
uint updateMode();
62-
void setUpdateMode(qulonglong value);
61+
quint64 updateMode();
62+
void setUpdateMode(quint64 value);
6363

6464
Q_PROPERTY(QList<QDBusObjectPath> JobList READ jobList NOTIFY JobListChanged)
6565
QList<QDBusObjectPath> jobList();
@@ -69,8 +69,8 @@ class UpdateDBusProxy : public QObject
6969

7070
QString hardwareId();
7171

72-
int checkUpdateMode();
73-
void setCheckUpdateMode(int value);
72+
quint64 checkUpdateMode();
73+
void setCheckUpdateMode(quint64 value);
7474

7575
QString idleDownloadConfig();
7676
QString downloadSpeedLimitConfig();

src/dcc-update-plugin/operation/updatemodel.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void UpdateModel::setLastCheckUpdateTime(const QString& lastTime)
287287
emit lastCheckUpdateTimeChanged();
288288
}
289289

290-
void UpdateModel::setCheckUpdateMode(int value)
290+
void UpdateModel::setCheckUpdateMode(quint64 value)
291291
{
292292
qCInfo(DCC_UPDATE_MODEL) << "Set check update mode: " << value;
293293
if (m_checkUpdateMode == value)
@@ -297,9 +297,17 @@ void UpdateModel::setCheckUpdateMode(int value)
297297
Q_EMIT checkUpdateModeChanged(value);
298298

299299
// 升级时切换用户,再切回来的时候收到的信号时乱序,可能会先收到updateStatusChanged再收到checkUpdateModeChanged
300+
refreshUpdateItemsChecked();
300301
refreshUpdateStatus();
301302
}
302303

304+
void UpdateModel::refreshUpdateItemsChecked()
305+
{
306+
for (const auto item : m_allUpdateInfos.values()) {
307+
item->setIsChecked(m_checkUpdateMode & item->updateType());
308+
}
309+
}
310+
303311
void UpdateModel::setPreUpdatelistModel(UpdateListModel *newPreUpdatelistModel)
304312
{
305313
if (m_preUpdatelistModel == newPreUpdatelistModel)
@@ -1156,9 +1164,9 @@ void UpdateModel::onUpdatePropertiesChanged(const QString& interfaceName, const
11561164
if (changedProperties.contains("CheckUpdateMode")) {
11571165
// 用户A、B都打开控制中心,用户A多次修改CheckUpdateMode后切换到用户B,控制中心会立刻收到多个改变信号
11581166
// 增加一个100ms的防抖,只取最后一次的数值
1159-
static int tmpValue = 0;
1167+
static quint64 tmpValue = 0;
11601168
static QTimer* timer = nullptr;
1161-
tmpValue = changedProperties.value("CheckUpdateMode").toInt();
1169+
tmpValue = changedProperties.value("CheckUpdateMode").toULongLong();
11621170
if (!timer) {
11631171
timer = new QTimer(this);
11641172
timer->setInterval(100);

src/dcc-update-plugin/operation/updatemodel.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ class UpdateModel : public QObject
136136
QString lastCheckUpdateTime() const { return m_lastCheckUpdateTime; }
137137
void setLastCheckUpdateTime(const QString &lastTime);
138138

139-
int checkUpdateMode() const { return m_checkUpdateMode; }
140-
void setCheckUpdateMode(int value);
141-
139+
quint64 checkUpdateMode() const { return m_checkUpdateMode; }
140+
void setCheckUpdateMode(quint64 value);
141+
void refreshUpdateItemsChecked();
142142

143143
// ---------------下载、备份、安装列表数据---------------
144144
UpdateListModel *preUpdatelistModel() const { return m_preUpdatelistModel; }
@@ -326,7 +326,7 @@ public slots:
326326
void checkUpdateErrTipsChanged();
327327
void checkBtnTextChanged();
328328
void lastCheckUpdateTimeChanged();
329-
void checkUpdateModeChanged(int);
329+
void checkUpdateModeChanged(quint64);
330330

331331
// 下载、备份、安装列表数据
332332
void preUpdatelistModelChanged();
@@ -396,7 +396,7 @@ public slots:
396396
QString m_checkUpdateErrTips;
397397
QString m_checkBtnText;
398398
QString m_lastCheckUpdateTime;
399-
int m_checkUpdateMode;
399+
quint64 m_checkUpdateMode;
400400

401401
// 下载、备份、安装列表数据
402402
UpdateListModel *m_preUpdatelistModel; // preUpdateList qml data

src/dcc-update-plugin/operation/updatework.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ void UpdateWorker::setUpdateInfo()
500500
isUpdated = false;
501501
}
502502
}
503+
m_model->refreshUpdateItemsChecked();
503504
m_model->refreshUpdateStatus();
504505
m_model->updateAvailableState();
505506
m_model->setLastStatus(isUpdated ? Updated : UpdatesAvailable, __LINE__);
@@ -1264,8 +1265,8 @@ void UpdateWorker::onRequestRetry(int type, int updateTypes)
12641265

12651266
void UpdateWorker::setCheckUpdateMode(int type, bool isChecked)
12661267
{
1267-
const int currentMode = m_model->checkUpdateMode();
1268-
const int outMode = isChecked ? (currentMode | type) : (currentMode & ~type);
1268+
quint64 currentMode = m_model->checkUpdateMode();
1269+
quint64 outMode = isChecked ? (currentMode | type) : (currentMode & ~type);
12691270

12701271
m_updateInter->setCheckUpdateMode(outMode);
12711272
}

0 commit comments

Comments
 (0)