mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
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:
parent
683c7d05a3
commit
e8c068db50
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user