[nautilus] batch-rename-dialog: don't transfer ownership from caller to called
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] batch-rename-dialog: don't transfer ownership from caller to called
- Date: Tue, 20 Sep 2016 14:46:13 +0000 (UTC)
commit 6053de7d94c961c9e945a2fcd81f915d9f94bcdc
Author: Carlos Soriano <csoriano gnome org>
Date: Fri Sep 16 10:03:15 2016 +0200
batch-rename-dialog: don't transfer ownership from caller to called
This is common good practice, otherwise it's not clear who has
ownership, making it error prone for dangling pointers (this case)
or use after free.
src/nautilus-batch-rename-dialog.c | 7 +++++--
src/nautilus-files-view.c | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index 5a60cdd..a545d2f 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -2032,6 +2032,9 @@ nautilus_batch_rename_dialog_finalize (GObject *object)
g_list_free_full (dialog->new_names, string_free);
g_list_free_full (dialog->duplicates, conflict_data_free);
+ nautilus_file_list_free (dialog->selection);
+ nautilus_directory_unref (dialog->directory);
+
G_OBJECT_CLASS (nautilus_batch_rename_dialog_parent_class)->finalize (object);
}
@@ -2100,8 +2103,8 @@ nautilus_batch_rename_dialog_new (GList *selection,
dialog = g_object_new (NAUTILUS_TYPE_BATCH_RENAME_DIALOG, "use-header-bar", TRUE, NULL);
- dialog->selection = selection;
- dialog->directory = directory;
+ dialog->selection = nautilus_file_list_copy (selection);
+ dialog->directory = nautilus_directory_ref (directory);
dialog->window = window;
gtk_window_set_transient_for (GTK_WINDOW (dialog),
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index d8aa3c6..11c5175 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -5971,7 +5971,7 @@ real_action_rename (NautilusFilesView *view)
cursor);
g_object_unref (cursor);
- dialog = nautilus_batch_rename_dialog_new (nautilus_files_view_get_selection (NAUTILUS_VIEW
(view)),
+ dialog = nautilus_batch_rename_dialog_new (selection,
nautilus_files_view_get_model (view),
nautilus_files_view_get_window (view));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]