mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 切换输入法导致内存泄露
多线程没有处理好同步关系,导致概率性创建对象后没有删除 Log: 修复切换输入法导致内存泄露的问题 Bug: https://pms.uniontech.com/bug-view-126381.html Influence: 切换输入法的场景 Change-Id: I2a2587d22592d23e1671e47902cc037f44ff6ec1
This commit is contained in:
parent
0d9b3820fd
commit
cab22dc6c1
@ -394,7 +394,7 @@ void TrayPlugin::addTrayWidget(const QString &itemKey, AbstractTrayWidget *trayW
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_trayMap.contains(itemKey) || m_trayMap.values().contains(trayWidget)) {
|
||||
if (m_trayMap.values().contains(trayWidget)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -438,13 +438,17 @@ void TrayPlugin::traySNIAdded(const QString &itemKey, const QString &sniServiceP
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_sniMutex);
|
||||
if (m_trayMap.contains(itemKey) || m_passiveSNITrayMap.contains(itemKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SNITrayWidget *trayWidget = new SNITrayWidget(sniServicePath);
|
||||
|
||||
// TODO(lxz): 在future里已经对dbus进行过检查了,这里应该不需要再次检查。
|
||||
if (!trayWidget->isValid())
|
||||
return;
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_sniMutex);
|
||||
if (trayWidget->status() == SNITrayWidget::ItemStatus::Passive) {
|
||||
m_passiveSNITrayMap.insert(itemKey, trayWidget);
|
||||
} else {
|
||||
@ -541,6 +545,7 @@ void TrayPlugin::trayRemoved(const QString &itemKey, const bool deleteObject)
|
||||
widget->setParent(nullptr);
|
||||
} else if (deleteObject) {
|
||||
widget->deleteLater();
|
||||
widget = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user