gnotificationbackend: Fix a GDBusConnection leak

`g_notification_backend_new_default()` adds a reference on
`backend->dbus_connection` (if non-`NULL`), but nothing ever unreffed
that.

Fix that by adding a dispose method.

In practice this is not really a problem, because the notification
backend is held alive by a `GApplication`, which lives as long as the
process. It’ll be a problem if someone is to ever add unit tests for
`GNotificationBackend`s though. So let’s fix it.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2022-11-15 17:50:03 +00:00
parent 683c7d05a3
commit e8c068db50

View File

@ -28,9 +28,23 @@
G_DEFINE_TYPE (GNotificationBackend, g_notification_backend, G_TYPE_OBJECT)
static void
g_notification_backend_dispose (GObject *obj)
{
GNotificationBackend *backend = G_NOTIFICATION_BACKEND (obj);
backend->application = NULL; /* no reference held, but clear the pointer anyway to avoid it dangling */
g_clear_object (&backend->dbus_connection);
G_OBJECT_CLASS (g_notification_backend_parent_class)->dispose (obj);
}
static void
g_notification_backend_class_init (GNotificationBackendClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = g_notification_backend_dispose;
}
static void