summaryrefslogtreecommitdiff
path: root/libcaja-private/caja-file-conflict-dialog.c
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2022-06-07 19:19:44 +0200
committerlukefromdc <[email protected]>2022-06-19 13:07:40 -0400
commit88197908a9cd6388b4b01605c6b0b25b64082008 (patch)
tree36cec359468bf2316df3f21d8b92d4a612733d40 /libcaja-private/caja-file-conflict-dialog.c
parent60b7fab5b9ad0b34414221cc68fea0ff465e5d9b (diff)
downloadcaja-88197908a9cd6388b4b01605c6b0b25b64082008.tar.bz2
caja-88197908a9cd6388b4b01605c6b0b25b64082008.tar.xz
caja-file-conflict-dialog: Move to automatic signal disconnection
Instead of manually keeping tabs on the signals so we can disconnect them before the data parameter gets destroyed, let GObject automatically track lifetime of the data, which it can do as that data is a GObject itself. This does not change behavior in the normal case, but makes sure the callback simply cannot get called with invalid/freed parameters, even if we did screw anything up (which we used to). This actually would have solved #1630 as well with using the target widgets as data parameters as the signal would have been disconnected as soon as the widget got destroyed, no matter whether we got finalized ourselves or not. The signal IDs were also use as guards to whether the monitor was set up for the related files, but we can just as well use the state of the file list ready handle which should only be NULL when we actually have monitors set up. Even if it wasn't the case, worse case scenario would be removing a non-existent monitor, which is perfectly OK anyway.
Diffstat (limited to 'libcaja-private/caja-file-conflict-dialog.c')
-rw-r--r--libcaja-private/caja-file-conflict-dialog.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/libcaja-private/caja-file-conflict-dialog.c b/libcaja-private/caja-file-conflict-dialog.c
index b58fda13..52be122f 100644
--- a/libcaja-private/caja-file-conflict-dialog.c
+++ b/libcaja-private/caja-file-conflict-dialog.c
@@ -46,8 +46,6 @@ struct _CajaFileConflictDialogPrivate
gchar *conflict_name;
CajaFileListHandle *handle;
- gulong src_handler_id;
- gulong dest_handler_id;
/* UI objects */
GtkWidget *titles_vbox;
@@ -361,12 +359,12 @@ file_list_ready_cb (GList *files,
caja_file_monitor_add (src, fcd, CAJA_FILE_ATTRIBUTES_FOR_ICON);
caja_file_monitor_add (dest, fcd, CAJA_FILE_ATTRIBUTES_FOR_ICON);
- details->src_handler_id = g_signal_connect (src, "changed",
- G_CALLBACK (file_icons_changed),
- fcd->details->src_image);
- details->dest_handler_id = g_signal_connect (dest, "changed",
- G_CALLBACK (file_icons_changed),
- fcd->details->dest_image);
+ g_signal_connect_object (src, "changed",
+ G_CALLBACK (file_icons_changed),
+ fcd->details->src_image, 0);
+ g_signal_connect_object (dest, "changed",
+ G_CALLBACK (file_icons_changed),
+ fcd->details->dest_image, 0);
}
static void
@@ -682,19 +680,12 @@ do_dispose (GObject *self)
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)
+ else
{
- g_signal_handler_disconnect (details->destination, details->dest_handler_id);
- caja_file_monitor_remove (details->destination, self);
- details->dest_handler_id = 0;
+ if (details->source)
+ caja_file_monitor_remove (details->source, self);
+ if (details->destination)
+ caja_file_monitor_remove (details->destination, self);
}
g_clear_pointer (&details->source, caja_file_unref);