mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: 解决协同服务崩溃后设备列表不清空和状态不改变的问题。
添加dbus服务watcher,当后台服务崩溃后,清空设备列表。 Log: Bug: https://pms.uniontech.com/bug-view-179595.html Influence: 协同服务崩溃后,设备列表显示及设备状态。 Change-Id: I8464aaac631eb2379475fbfb65eaba3ab063448e
This commit is contained in:
parent
105df289cc
commit
4faedb08b8
@ -26,6 +26,7 @@
|
||||
#include <QDBusArgument>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusPendingCall>
|
||||
#include <QDBusServiceWatcher>
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
@ -56,16 +57,19 @@ CollaborationDevModel::CollaborationDevModel(QObject *parent)
|
||||
|
||||
m_colDbusInter->connection().connect(CollaborationService, CollaborationPath, ColPropertiesInterface,
|
||||
"PropertiesChanged", "sa{sv}as", this, SLOT(onPropertyChanged(QDBusMessage)));
|
||||
|
||||
auto *dbusWatcher = new QDBusServiceWatcher(CollaborationService, m_colDbusInter->connection(),
|
||||
QDBusServiceWatcher::WatchForUnregistration, this);
|
||||
connect(dbusWatcher, &QDBusServiceWatcher::serviceUnregistered, this, [this](){
|
||||
qWarning() << CollaborationService << "unregistered";
|
||||
clear();
|
||||
});
|
||||
}
|
||||
|
||||
void CollaborationDevModel::checkServiceValid()
|
||||
{
|
||||
if (!m_colDbusInter->isValid()) {
|
||||
for (CollaborationDevice *device : m_devices) {
|
||||
device->deleteLater();
|
||||
}
|
||||
m_devices.clear();
|
||||
Q_EMIT devicesChanged();
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,6 +130,16 @@ void CollaborationDevModel::updateDevice(const QStringList &devPaths)
|
||||
emit devicesChanged();
|
||||
}
|
||||
|
||||
void CollaborationDevModel::clear()
|
||||
{
|
||||
for (CollaborationDevice *device : m_devices) {
|
||||
device->deleteLater();
|
||||
}
|
||||
m_devices.clear();
|
||||
|
||||
Q_EMIT devicesChanged();
|
||||
}
|
||||
|
||||
CollaborationDevice *CollaborationDevModel::getDevice(const QString &machinePath)
|
||||
{
|
||||
return m_devices.value(machinePath, nullptr);
|
||||
|
@ -53,6 +53,7 @@ private slots:
|
||||
|
||||
private:
|
||||
void updateDevice(const QStringList &devPaths);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
QDBusInterface *m_colDbusInter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user