From 8232d384929641be7409e026d20843a2edd73e48 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 13 Apr 2021 16:33:13 +0200 Subject: [PATCH] notifications: Handle MaxNotificationsExceeded error from GNOME Flashback (cherry picked from commit 2cfc64579a22e7dd933c9591e6bb141b877b58e0) --- qutebrowser/browser/webengine/notification.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/webengine/notification.py b/qutebrowser/browser/webengine/notification.py index 36493f4f72..5e32b63276 100644 --- a/qutebrowser/browser/webengine/notification.py +++ b/qutebrowser/browser/webengine/notification.py @@ -693,6 +693,15 @@ class DBusNotificationAdapter(AbstractNotificationAdapter): SPEC_VERSION = "1.2" # Released in January 2011, still current in March 2021. NAME = "libnotify" + _NON_FATAL_ERRORS = { + # notification daemon is gone + "org.freedesktop.DBus.Error.NoReply", + + # https://gitlab.gnome.org/GNOME/gnome-flashback/-/blob/3.40.0/gnome-flashback/libnotifications/nd-daemon.c#L178-187 + # Exceeded maximum number of notifications + "org.freedesktop.Notifications.MaxNotificationsExceeded", + } + def __init__(self, parent: QObject = None) -> None: super().__init__(bridge) if not qtutils.version_check('5.14'): @@ -878,8 +887,8 @@ def _verify_message( if msg.type() == QDBusMessage.ErrorMessage: err = msg.errorName() - if err == "org.freedesktop.DBus.Error.NoReply": - self.error.emit(msg.errorMessage()) # notification daemon is gone + if err in self._NON_FATAL_ERRORS: + self.error.emit(msg.errorMessage()) return raise Error(f"Got DBus error: {err} - {msg.errorMessage()}")