[nautilus/wip/csoriano/debug: 8/8] 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/wip/csoriano/debug: 8/8] batch-rename-dialog: don't transfer ownership from caller to called
- Date: Mon, 19 Sep 2016 18:55:21 +0000 (UTC)
commit d3036f19a6eca8004a08e970be4fe5760dd17607
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 | 11 +++++++----
src/nautilus-files-view.c | 2 +-
2 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index 59a15a1..de41d4f 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -1286,7 +1286,7 @@ file_names_list_has_duplicates_async_thread (GTask *task,
{
if (g_task_return_error_if_cancelled (task))
{
- nautilus_directory_list_unref (directories);
+ nautilus_directory_list_free (directories);
return;
}
@@ -1315,7 +1315,7 @@ file_names_list_has_duplicates_async_thread (GTask *task,
}
g_task_return_boolean (task, TRUE);
- nautilus_directory_list_unref (directories);
+ nautilus_directory_list_free (directories);
g_print ("unrefing directory \n");
}
@@ -2044,6 +2044,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);
}
@@ -2112,8 +2115,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 e613a01..ca6b9ea 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]