summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexandru Pandelea <alexandru.pandelea@gmail.com>2016-09-07 22:39:02 +0300
committerAlexandru Pandelea <alexandru.pandelea@gmail.com>2016-09-08 22:04:38 +0300
commitf686cc9219383a7cd1d7dfc6fefb553e4c330d39 (patch)
tree6d51814521719cf75ae9254e525f3ad694964b6b /src
parent2f878b79c43676eef37e00a1e1d4b1572d2cf341 (diff)
downloadnautilus-f686cc9219383a7cd1d7dfc6fefb553e4c330d39.tar.gz
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
Diffstat (limited to 'src')
-rw-r--r--src/nautilus-file.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 541275875..3ef33e143 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));