Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions network-service-plugin/src/session/networkstatehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
Comment on lines +917 to +922
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Resetting m_replacesId on any NotificationClosed may interfere with other notifications.

m_replacesId is cleared whenever any notification closes, even if it’s not one created by this class. In a shared notification daemon, this can cause us to lose our replacement ID for unrelated notifications and break replace-id behavior. Please only reset m_replacesId when id == m_replacesId, which will also let you remove the Q_UNUSED(id).

Suggested change
void NetworkStateHandler::onNotificationClosed(uint id, uint reason)
{
Q_UNUSED(id);
Q_UNUSED(reason);
m_replacesId = 0;
}
void NetworkStateHandler::onNotificationClosed(uint id, uint reason)
{
Q_UNUSED(reason);
if (id == m_replacesId) {
m_replacesId = 0;
}
}


NetworkStateHandler::ConnectionType NetworkStateHandler::getCustomConnectionType(NetworkManager::ConnectionSettings *settings)
{
auto t = settings->connectionType();
Expand Down
3 changes: 3 additions & 0 deletions network-service-plugin/src/session/networkstatehandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading