[balsa] Unref structure members in a dispose method
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Unref structure members in a dispose method
- Date: Mon, 12 Aug 2019 19:41:53 +0000 (UTC)
commit e946cc340d7345f53b2fffa39d1ecff159fa8b14
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Aug 12 15:41:30 2019 -0400
Unref structure members in a dispose method
* libbalsa/libbalsa-vfs.c (libbalsa_vfs_class_init),
(libbalsa_vfs_dispose), (libbalsa_vfs_finalize):
ChangeLog | 7 +++++++
libbalsa/libbalsa-vfs.c | 29 +++++++++++++++++++----------
2 files changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a5f5d914a..344e63655 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-08-12 Peter Bloomfield <pbloomfield bellsouth net>
+
+ Unref structure members in a dispose method
+
+ * libbalsa/libbalsa-vfs.c (libbalsa_vfs_class_init),
+ (libbalsa_vfs_dispose), (libbalsa_vfs_finalize):
+
2019-08-12 Peter Bloomfield <pbloomfield bellsouth net>
In calls to g_signal_connect_swapped(), do not cast data using
diff --git a/libbalsa/libbalsa-vfs.c b/libbalsa/libbalsa-vfs.c
index 8790e0fe4..9d8013c8d 100644
--- a/libbalsa/libbalsa-vfs.c
+++ b/libbalsa/libbalsa-vfs.c
@@ -63,7 +63,8 @@ struct _LibbalsaVfs {
};
-static void libbalsa_vfs_finalize(LibbalsaVfs * self);
+static void libbalsa_vfs_dispose(GObject *object);
+static void libbalsa_vfs_finalize(GObject *object);
gboolean
@@ -81,8 +82,8 @@ libbalsa_vfs_class_init(LibbalsaVfsClass * klass)
{
GObjectClass *gobject_klass = G_OBJECT_CLASS(klass);
- gobject_klass->finalize =
- (GObjectFinalizeFunc) libbalsa_vfs_finalize;
+ gobject_klass->dispose = libbalsa_vfs_dispose;
+ gobject_klass->finalize = libbalsa_vfs_finalize;
}
@@ -94,21 +95,29 @@ libbalsa_vfs_init(LibbalsaVfs * self)
static void
-libbalsa_vfs_finalize(LibbalsaVfs * self)
+libbalsa_vfs_dispose(GObject *object)
{
- g_return_if_fail(LIBBALSA_IS_VFS(self));
+ LibbalsaVfs *self = LIBBALSA_VFS(object);
+
+ g_clear_object(&self->gio_gfile);
+ g_clear_object(&self->info);
+
+ G_OBJECT_CLASS(libbalsa_vfs_parent_class)->dispose(object);
+}
+
+
+static void
+libbalsa_vfs_finalize(GObject *object)
+{
+ LibbalsaVfs *self = LIBBALSA_VFS(object);
g_free(self->file_uri);
g_free(self->file_utf8);
g_free(self->folder_uri);
g_free(self->mime_type);
g_free(self->charset);
- if (self->gio_gfile != NULL)
- g_object_unref(self->gio_gfile);
- if (self->info != NULL)
- g_object_unref(self->info);
- G_OBJECT_CLASS(libbalsa_vfs_parent_class)->finalize(G_OBJECT(self));
+ G_OBJECT_CLASS(libbalsa_vfs_parent_class)->finalize(object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]