mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: dock crash and sni tray status property process
https://github.com/linuxdeepin/internal-discussion/issues/804 Change-Id: Ib288e1248d64f4ed034fbfa876c2f508eb84e2f8
This commit is contained in:
parent
945d58a4b5
commit
8ed1aa962f
Notes:
gerrit
2019-01-08 15:49:08 +08:00
Verified+1: <jenkins@deepin.com> Verified+1: liuwen123 <liuwen@linuxdeepin.com> Code-Review+2: listenerri <listenerri@gmail.com> Submitted-by: listenerri <listenerri@gmail.com> Submitted-at: Tue, 08 Jan 2019 15:49:07 +0800 Reviewed-on: https://cr.deepin.io/41175 Project: dde/dde-dock Branch: refs/heads/master
@ -138,7 +138,7 @@ QString SNITrayWidget::toSNIKey(const QString &sniServicePath)
|
||||
|
||||
do {
|
||||
const QPair<QString, QString> &sap = serviceAndPath(sniServicePath);
|
||||
key = QDBusInterface(sap.first, sap.second).property("Id").toString();
|
||||
key = QDBusInterface(sap.first, sap.second, StatusNotifierItem::staticInterfaceName()).property("Id").toString();
|
||||
if (!key.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
@ -288,6 +288,12 @@ void TrayPlugin::sniItemsChanged()
|
||||
trayRemoved(itemKey);
|
||||
}
|
||||
}
|
||||
const QList<QString> &passiveSNIKeyList = m_passiveSNITrayMap.keys();
|
||||
for (auto itemKey : passiveSNIKeyList) {
|
||||
if (!sinTrayKeyList.contains(itemKey) && SNITrayWidget::isSNIKey(itemKey)) {
|
||||
m_passiveSNITrayMap.take(itemKey)->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < sinTrayKeyList.size(); ++i) {
|
||||
traySNIAdded(sinTrayKeyList.at(i), itemServicePaths.at(i));
|
||||
@ -347,13 +353,13 @@ void TrayPlugin::trayXWindowAdded(const QString &itemKey, quint32 winId)
|
||||
|
||||
void TrayPlugin::traySNIAdded(const QString &itemKey, const QString &sniServicePath)
|
||||
{
|
||||
if (m_trayMap.contains(itemKey) || !SNITrayWidget::isSNIKey(itemKey)) {
|
||||
if (m_trayMap.contains(itemKey) || !SNITrayWidget::isSNIKey(itemKey) || m_passiveSNITrayMap.contains(itemKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SNITrayWidget *trayWidget = new SNITrayWidget(sniServicePath);
|
||||
if (trayWidget->status() == SNITrayWidget::ItemStatus::Passive) {
|
||||
m_trayMap.insert(itemKey, trayWidget);
|
||||
m_passiveSNITrayMap.insert(itemKey, trayWidget);
|
||||
} else {
|
||||
addTrayWidget(itemKey, trayWidget);
|
||||
}
|
||||
@ -395,7 +401,7 @@ void TrayPlugin::trayRemoved(const QString &itemKey, const bool deleteObject)
|
||||
return;
|
||||
}
|
||||
|
||||
AbstractTrayWidget *widget = m_trayMap.value(itemKey);
|
||||
AbstractTrayWidget *widget = m_trayMap.take(itemKey);
|
||||
|
||||
if (displayMode() == Dock::Efficient) {
|
||||
m_proxyInter->itemRemoved(this, itemKey);
|
||||
@ -408,7 +414,6 @@ void TrayPlugin::trayRemoved(const QString &itemKey, const bool deleteObject)
|
||||
if (widget->trayTyep() == AbstractTrayWidget::TrayType::SystemTray) {
|
||||
widget->setParent(nullptr);
|
||||
} else if (deleteObject) {
|
||||
m_trayMap.remove(itemKey);
|
||||
widget->deleteLater();
|
||||
}
|
||||
}
|
||||
@ -479,18 +484,33 @@ void TrayPlugin::onRequestRefershWindowVisible()
|
||||
void TrayPlugin::onSNIItemStatusChanged(SNITrayWidget::ItemStatus status)
|
||||
{
|
||||
SNITrayWidget *trayWidget = static_cast<SNITrayWidget *>(sender());
|
||||
const QString &itemKey = m_trayMap.key(trayWidget);
|
||||
if (!trayWidget || itemKey.isEmpty()) {
|
||||
if (!trayWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString itemKey;
|
||||
do {
|
||||
itemKey = m_trayMap.key(trayWidget);
|
||||
if (!itemKey.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
itemKey = m_passiveSNITrayMap.key(trayWidget);
|
||||
if (itemKey.isEmpty()) {
|
||||
qDebug() << "Error! not found the status changed SNI tray!";
|
||||
return;
|
||||
}
|
||||
} while (false);
|
||||
|
||||
switch (status) {
|
||||
case SNITrayWidget::Passive: {
|
||||
m_passiveSNITrayMap.insert(itemKey, trayWidget);
|
||||
trayRemoved(itemKey, false);
|
||||
break;
|
||||
}
|
||||
case SNITrayWidget::Active:
|
||||
case SNITrayWidget::NeedsAttention: {
|
||||
m_passiveSNITrayMap.remove(itemKey);
|
||||
addTrayWidget(itemKey, trayWidget);
|
||||
break;
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ private:
|
||||
QDBusConnectionInterface *m_dbusDaemonInterface;
|
||||
|
||||
QMap<QString, AbstractTrayWidget *> m_trayMap;
|
||||
QMap<QString, SNITrayWidget *> m_passiveSNITrayMap;
|
||||
QMap<QString, IndicatorTray*> m_indicatorMap;
|
||||
QString m_sniHostService;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user