mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: 任务栏蓝牙插件设备列表无法刷新
在刚开机时,蓝牙插件在获取适配器信息时,可能在将检测到的设备ID与已存在的设备列表比较时,将检测到的ID存入QMap,但是没有存入对象, 后面仅通过判断ID时,认为适配器已经加入QMap中,就不再加入设备对象,后面在判断对象是否为空的地方,都直接返回了,导致信号连接没有触发。 Log: 修复任务栏蓝牙插件设备列表无法刷新的问题。 Bug: https://pms.uniontech.com/zentao/bug-view-57913.html Change-Id: If43ae449e378fde23649eba2fd4208a4d01b375d
This commit is contained in:
parent
3250451447
commit
1fe8ddfcac
@ -150,6 +150,10 @@ void AdaptersManager::onAdapterPropertiesChanged(const QString &json)
|
||||
const QString id = obj["Path"].toString();
|
||||
QDBusObjectPath dPath(id);
|
||||
|
||||
if (!m_adapters.contains(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Adapter *adapter = const_cast<Adapter *>(m_adapters[id]);
|
||||
if (adapter) {
|
||||
inflateAdapter(adapter, obj);
|
||||
@ -180,6 +184,10 @@ void AdaptersManager::removeAdapter(const QString &json)
|
||||
QJsonObject obj = doc.object();
|
||||
const QString id = obj["Path"].toString();
|
||||
|
||||
if (!m_adapters.contains(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Adapter *result = m_adapters[id];
|
||||
Adapter *adapter = const_cast<Adapter *>(result);
|
||||
if (adapter) {
|
||||
@ -196,6 +204,10 @@ void AdaptersManager::addDevice(const QString &json)
|
||||
const QString adapterId = obj["AdapterPath"].toString();
|
||||
const QString deviceId = obj["Path"].toString();
|
||||
|
||||
if (!m_adapters.contains(adapterId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Adapter *result = m_adapters[adapterId];
|
||||
Adapter *adapter = const_cast<Adapter *>(result);
|
||||
if (adapter) {
|
||||
@ -214,6 +226,10 @@ void AdaptersManager::removeDevice(const QString &json)
|
||||
const QString adapterId = obj["AdapterPath"].toString();
|
||||
const QString deviceId = obj["Path"].toString();
|
||||
|
||||
if (!m_adapters.contains(adapterId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Adapter *result = m_adapters[adapterId];
|
||||
Adapter *adapter = const_cast<Adapter *>(result);
|
||||
if (adapter) {
|
||||
@ -247,11 +263,11 @@ void AdaptersManager::adapterAdd(Adapter *adapter, const QJsonObject &adpterObj)
|
||||
|
||||
QString id = adapter->id();
|
||||
if (!id.isEmpty()) {
|
||||
// in case memory leaks
|
||||
if (m_adapters.contains(id)) {
|
||||
return;
|
||||
if (!m_adapters.contains(id)) {
|
||||
m_adapters[id] = adapter;
|
||||
} else if (m_adapters[id] == nullptr) {
|
||||
m_adapters[id] = adapter;
|
||||
}
|
||||
m_adapters[id] = adapter;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user