From 7e110ff93a2d6c89f87a4bbb79adf4d9a33c19d0 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 7 Jun 2022 18:49:00 +0200 Subject: caja-file-conflict-dialog: Properly release references on dispose() Fixes #1630. --- libcaja-private/caja-file-conflict-dialog.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-file-conflict-dialog.c b/libcaja-private/caja-file-conflict-dialog.c index 233f47ae..b58fda13 100644 --- a/libcaja-private/caja-file-conflict-dialog.c +++ b/libcaja-private/caja-file-conflict-dialog.c @@ -672,33 +672,45 @@ caja_file_conflict_dialog_init (CajaFileConflictDialog *fcd) } static void -do_finalize (GObject *self) +do_dispose (GObject *self) { CajaFileConflictDialogPrivate *details = CAJA_FILE_CONFLICT_DIALOG (self)->details; - g_free (details->conflict_name); - if (details->handle != NULL) { caja_file_list_cancel_call_when_ready (details->handle); + details->handle = NULL; } if (details->src_handler_id) { g_signal_handler_disconnect (details->source, details->src_handler_id); caja_file_monitor_remove (details->source, self); + details->src_handler_id = 0; } if (details->dest_handler_id) { g_signal_handler_disconnect (details->destination, details->dest_handler_id); caja_file_monitor_remove (details->destination, self); + details->dest_handler_id = 0; } - caja_file_unref (details->source); - caja_file_unref (details->destination); - caja_file_unref (details->dest_dir); + g_clear_pointer (&details->source, caja_file_unref); + g_clear_pointer (&details->destination, caja_file_unref); + g_clear_pointer (&details->dest_dir, caja_file_unref); + + G_OBJECT_CLASS (caja_file_conflict_dialog_parent_class)->dispose (self); +} + +static void +do_finalize (GObject *self) +{ + CajaFileConflictDialogPrivate *details = + CAJA_FILE_CONFLICT_DIALOG (self)->details; + + g_free (details->conflict_name); G_OBJECT_CLASS (caja_file_conflict_dialog_parent_class)->finalize (self); } @@ -706,6 +718,7 @@ do_finalize (GObject *self) static void caja_file_conflict_dialog_class_init (CajaFileConflictDialogClass *klass) { + G_OBJECT_CLASS (klass)->dispose = do_dispose; G_OBJECT_CLASS (klass)->finalize = do_finalize; } -- cgit v1.2.1