summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Li <gary.li1@uwaterloo.ca>2022-10-10 20:25:33 -0400
committerAntónio Fernandes <antoniof@gnome.org>2023-01-06 19:34:10 +0000
commitb4131eacebb2c4c949459fa5750d4393b8507d80 (patch)
tree8b4d53c82cf51820b870b16a3dfe52b7a48a9329
parenta7a682a712fcd78f68430fd7ced65dfe0d0f00c1 (diff)
downloadnautilus-b4131eacebb2c4c949459fa5750d4393b8507d80.tar.gz
progress-indicator: Disconnect signals from cancelled operations
If the user cancels an operation and closes the window, Files crashes. This happens because disconnect_progress_infos() does not disconnect all signals taking *self as data, allowing use-after-free bugs. Use g_signal_connect_object() to fix this implicitly. Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/1965
-rw-r--r--src/nautilus-progress-indicator.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nautilus-progress-indicator.c b/src/nautilus-progress-indicator.c
index ce857047c..c49be9fb9 100644
--- a/src/nautilus-progress-indicator.c
+++ b/src/nautilus-progress-indicator.c
@@ -254,12 +254,12 @@ update_operations (NautilusProgressIndicator *self)
should_show_progress_button = should_show_progress_button ||
should_show_progress_info (l->data);
- g_signal_connect_swapped (l->data, "finished",
- G_CALLBACK (on_progress_info_finished), self);
- g_signal_connect_swapped (l->data, "cancelled",
- G_CALLBACK (on_progress_info_cancelled), self);
- g_signal_connect_swapped (l->data, "progress-changed",
- G_CALLBACK (on_progress_info_progress_changed), self);
+ g_signal_connect_object (l->data, "finished",
+ G_CALLBACK (on_progress_info_finished), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (l->data, "cancelled",
+ G_CALLBACK (on_progress_info_cancelled), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (l->data, "progress-changed",
+ G_CALLBACK (on_progress_info_progress_changed), self, G_CONNECT_SWAPPED);
g_list_store_append (self->progress_infos_model, l->data);
}