[nautilus] nautilus-file: Fix segfault on undo for batch rename
- From: Alexandru-Ionut Pandelea <alexpandelea src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] nautilus-file: Fix segfault on undo for batch rename
- Date: Thu, 8 Sep 2016 19:05:12 +0000 (UTC)
commit f686cc9219383a7cd1d7dfc6fefb553e4c330d39
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date: Wed Sep 7 22:39:02 2016 +0300
nautilus-file: Fix segfault on undo for batch rename
In some cases, if some of the files are not renamed, for reasons like
deletion or files having the same name, the undo would fail.
The problem was that the files and names lists provided for undo also
contained info about the files for which the rename failed.
The fix was to add undo info only for files that are actually renamed
and prepare the undo only if at least a file has successfully been
renamed.
https://bugzilla.gnome.org/show_bug.cgi?id=770965
src/nautilus-file.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 5412758..3ef33e1 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -2295,7 +2295,6 @@ real_batch_rename (GList *files,
new_name = l2->data;
location = nautilus_file_get_location (file);
- old_files = g_list_append (old_files, location);
new_file_name = nautilus_file_can_rename_file (file,
new_name->str,
@@ -2306,11 +2305,12 @@ real_batch_rename (GList *files,
{
op->skipped_files++;
- new_file = nautilus_file_get_location (file);
- new_files = g_list_append (new_files, new_file);
-
continue;
}
+ else
+ {
+ old_files = g_list_append (old_files, location);
+ }
g_assert (G_IS_FILE (location));
@@ -2342,8 +2342,9 @@ real_batch_rename (GList *files,
}
}
- /* Tell the undo manager a batch rename is taking place */
- if (!nautilus_file_undo_manager_is_operating ())
+ /* Tell the undo manager a batch rename is taking place if at least
+ * a file has been renamed*/
+ if (!nautilus_file_undo_manager_is_operating () && op->skipped_files != g_list_length (files))
{
op->undo_info = nautilus_file_undo_info_batch_rename_new (g_list_length (new_files));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]