From 100adbdacce42d4cbfee6b78fd7f22233fde8e64 Mon Sep 17 00:00:00 2001 From: donghualin Date: Thu, 12 Mar 2026 13:29:40 +0800 Subject: [PATCH] fix: Fix missing notification after closing network MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the previous notification dialog was closed, the local cache did not update the replaceId. The OSD service still received the replaceId from before the network was closed. At this point, the corresponding message box had already disappeared, so the notification was not displayed again. Log: Fix missing notification after closing network PMS: BUG-351867 fix: 修复关闭网络后没有通知 在上一个通知对话框关闭后,本地缓存没有更新replaceId,osd服务接收到的依然是兑换卡关闭之前的replaceId,此时对应的消息框已经消失,就没有再次显示消息框 --- .../src/session/networkstatehandler.cpp | 8 ++++++++ network-service-plugin/src/session/networkstatehandler.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/network-service-plugin/src/session/networkstatehandler.cpp b/network-service-plugin/src/session/networkstatehandler.cpp index 4263abc7..a10e5743 100644 --- a/network-service-plugin/src/session/networkstatehandler.cpp +++ b/network-service-plugin/src/session/networkstatehandler.cpp @@ -77,6 +77,7 @@ NetworkStateHandler::NetworkStateHandler(QObject *parent) QDBusConnection::systemBus().connect("org.deepin.dde.Network1", "/org/deepin/dde/Network1", "org.deepin.dde.Network1", "DeviceEnabled", this, SLOT(onDeviceEnabled(QDBusObjectPath, bool))); QDBusConnection::systemBus().connect("org.freedesktop.NetworkManager", "", "org.freedesktop.NetworkManager.VPN.Connection", "VpnStateChanged", this, SLOT(onVpnStateChanged(QDBusMessage))); QDBusConnection::systemBus().connect("org.deepin.dde.AirplaneMode1", "/org/deepin/dde/AirplaneMode1", DBUS_PROPERTIES_IFACE, "PropertiesChanged", this, SLOT(onAirplaneModePropertiesChanged(QString, QVariantMap, QStringList))); + QDBusConnection::sessionBus().connect("org.deepin.dde.Notification1", "/org/freedesktop/Notifications", "org.deepin.dde.Notification1", "NotificationClosed", this, SLOT(onNotificationClosed(uint, uint))); // 迁移dde-daemon/session/power1/sleep_inhibit.go ConnectHandleForSleep处理 QDBusConnection::systemBus().connect("org.deepin.dde.Daemon1", "/org/deepin/dde/Daemon1", "org.deepin.dde.Daemon1", "HandleForSleep", this, SLOT(onHandleForSleep(bool))); QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetNameOwner"); @@ -913,6 +914,13 @@ void NetworkStateHandler::notifyVpnFailed(const QString &id, uint reason) notify(notifyIconVpnDisconnected, tr("Disconnected"), m_vpnErrorTable[reason]); } +void NetworkStateHandler::onNotificationClosed(uint id, uint reason) +{ + Q_UNUSED(id); + Q_UNUSED(reason); + m_replacesId = 0; +} + NetworkStateHandler::ConnectionType NetworkStateHandler::getCustomConnectionType(NetworkManager::ConnectionSettings *settings) { auto t = settings->connectionType(); diff --git a/network-service-plugin/src/session/networkstatehandler.h b/network-service-plugin/src/session/networkstatehandler.h index 9efb19a2..8e0da3a9 100644 --- a/network-service-plugin/src/session/networkstatehandler.h +++ b/network-service-plugin/src/session/networkstatehandler.h @@ -130,6 +130,9 @@ public Q_SLOTS: void notifyVpnDisconnected(const QString &id); void notifyVpnFailed(const QString &id, uint reason); +private Q_SLOTS: + void onNotificationClosed(uint id, uint reason); + private: bool m_notifyEnabled; QDBusServiceWatcher *m_dbusService;