mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix(bluetooth): 当蓝牙适配器id相同时,为了防止内存泄露,不应该替换map的元素。
Adapter为动态分配的内存空间,如果直接替换,可能导致这个变量无法被管理。所以如果传入相同的id指代的应该是同一个适配器,不需要替换。 Log: 当蓝牙适配器id相同时,为了防止内存泄露,不应该替换map的元素。 Change-Id: I3f0a4b9f46d728cc70c3d8a57cefa4fda2b908d8
This commit is contained in:
parent
5da7670e60
commit
a19ecbe757
@ -247,6 +247,10 @@ void AdaptersManager::adapterAdd(Adapter *adapter, const QJsonObject &adpterObj)
|
|||||||
|
|
||||||
QString id = adapter->id();
|
QString id = adapter->id();
|
||||||
if (!id.isEmpty()) {
|
if (!id.isEmpty()) {
|
||||||
|
// in case memory leaks
|
||||||
|
if (m_adapters.contains(id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_adapters[id] = adapter;
|
m_adapters[id] = adapter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user