Skip to content

Commit 614d0d0

Browse files
committed
fix: resolve hotspot device not updating when network interface changes
Changed from QTimer to counter mechanism for handling network configuration updates Removed QTimer and replaced with integer counter to track update cycles Fixed issue where hotspot devices were not properly updated when network interfaces changed The previous timer approach could miss updates if network changes occurred rapidly New counter mechanism ensures proper sequencing of configuration updates Log: Fixed hotspot device update issue when network interfaces change Influence: 1. Test hotspot functionality after network interface changes 2. Verify hotspot configuration updates properly 3. Check that password retrieval works correctly after network changes 4. Test multiple rapid network interface changes 5. Verify user active state handling remains functional fix: 修复网卡变化时热点设备未更新问题 从 QTimer 改为计数器机制处理网络配置更新 移除 QTimer 并使用整数计数器跟踪更新周期 修复当网络接口变化时热点设备未能正确更新的问题 之前的定时器方法在快速网络变化时可能错过更新 新的计数器机制确保配置更新的正确顺序 Log: 修复网卡变化时热点设备更新问题 Influence: 1. 测试网络接口变化后的热点功能 2. 验证热点配置是否正确更新 3. 检查网络变化后密码获取功能是否正常 4. 测试多次快速网络接口变化 5. 验证用户活跃状态处理保持正常 PMS: BUG-303389
1 parent 03b0ef4 commit 614d0d0

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

net-view/operation/private/nethotspotcontroller.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ NetHotspotController::NetHotspotController(QObject *parent)
2020
, m_enabledable(true)
2121
, m_deviceEnabled(true)
2222
, m_userActive(true)
23-
, m_updatedTimer(new QTimer(this))
23+
, m_updateCount(0)
2424
{
25-
m_updatedTimer->setSingleShot(true);
26-
m_updatedTimer->setInterval(50);
2725
m_hotspotController = NetworkController::instance()->hotspotController();
2826
updateData();
2927
updateConfig();
@@ -34,7 +32,7 @@ NetHotspotController::NetHotspotController(QObject *parent)
3432
connect(m_hotspotController, &HotspotController::activeConnectionChanged, this, &NetHotspotController::updateConfig);
3533
connect(m_hotspotController, &HotspotController::itemAdded, this, &NetHotspotController::updateConfig);
3634
connect(m_hotspotController, &HotspotController::itemRemoved, this, &NetHotspotController::updateConfig);
37-
connect(m_hotspotController, &HotspotController::itemChanged, this, &NetHotspotController::updateConfig, Qt::QueuedConnection);
35+
connect(m_hotspotController, &HotspotController::itemChanged, this, &NetHotspotController::onItemChanged, Qt::QueuedConnection);
3836
QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.login1", "/org/freedesktop/login1/user/self", "org.freedesktop.DBus.Properties", "Get");
3937
msg << "org.freedesktop.login1.User" << "Display";
4038
QDBusConnection::systemBus().callWithCallback(msg, this, SLOT(updateDisplay(QDBusVariant)));
@@ -131,12 +129,13 @@ void NetHotspotController::updateData()
131129
}
132130
updateEnabled();
133131
updateEnabledable();
132+
updateConfig();
134133
}
135134

136135
void NetHotspotController::updateConfig()
137136
{
138137
// 用户不为Active状态时,获取密码需要认证
139-
if (!m_userActive || m_updatedTimer->isActive()) {
138+
if (!m_userActive) {
140139
return;
141140
}
142141
QList<HotspotItem *> items;
@@ -176,7 +175,7 @@ void NetHotspotController::updateConfig()
176175
ipv4Setting->setInitialized(true);
177176
} else {
178177
// conn->secrets会触发两次itemChanged信号
179-
m_updatedTimer->start();
178+
m_updateCount = 2;
180179
NetworkManager::WirelessSecuritySetting::Ptr const sSetting = settings->setting(NetworkManager::Setting::SettingType::WirelessSecurity).staticCast<NetworkManager::WirelessSecuritySetting>();
181180
sSetting->secretsFromMap(conn->secrets(sSetting->name()).value().value(sSetting->name()));
182181
}
@@ -226,5 +225,14 @@ void NetHotspotController::updateDisplay(const QDBusVariant &display)
226225
});
227226
}
228227

228+
void NetHotspotController::onItemChanged()
229+
{
230+
if (m_updateCount > 0) {
231+
m_updateCount--;
232+
} else {
233+
updateConfig();
234+
}
235+
}
236+
229237
} // namespace network
230238
} // namespace dde

net-view/operation/private/nethotspotcontroller.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private Q_SLOTS:
4646
void updateConfig();
4747
void onLoginSessionPropertiesChanged(const QString &, const QVariantMap &properties, const QStringList &);
4848
void updateDisplay(const QDBusVariant &display);
49+
void onItemChanged();
4950

5051
private:
5152
HotspotController *m_hotspotController;
@@ -57,7 +58,7 @@ private Q_SLOTS:
5758
QStringList m_shareDevice;
5859
QStringList m_optionalDevice;
5960
QStringList m_optionalDevicePath;
60-
QTimer *m_updatedTimer;
61+
int m_updateCount;
6162
};
6263
} // namespace network
6364
} // namespace dde

0 commit comments

Comments
 (0)