[nautilus/alex-fazakas-operations-undo-redo: 2/4] file-operations: Set sync operations undo info
- From: Alexandru Fazakas <alexfazakas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/alex-fazakas-operations-undo-redo: 2/4] file-operations: Set sync operations undo info
- Date: Tue, 31 Jul 2018 09:02:38 +0000 (UTC)
commit 85ba118cbb4e4142974df19b6bddce6cd218a818
Author: Alexandru Fazakas <alex fazakas97 gmail com>
Date: Thu Jul 26 13:32:10 2018 +0300
file-operations: Set sync operations undo info
Since most synchronous operations rely on g_task_run_in_thread_sync and
this doesn't reach callbacks, we need to manually set the undo info.
This patch fixes this by moving the callback function content in-line.
src/nautilus-file-operations.c | 62 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index 589602cbb..29b83a9c0 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -2536,6 +2536,7 @@ trash_or_delete_internal_sync (GList *files,
{
GTask *task;
DeleteJob *job;
+ GHashTable *debuting_uris;
job = setup_delete_job (files,
parent_window,
@@ -2543,10 +2544,25 @@ trash_or_delete_internal_sync (GList *files,
done_callback,
done_callback_data);
- task = g_task_new (NULL, NULL, delete_task_done, job);
+ task = g_task_new (NULL, NULL, NULL, job);
g_task_set_task_data (task, job, NULL);
g_task_run_in_thread_sync (task, trash_or_delete_internal);
g_object_unref (task);
+ /* Since g_task_run_in_thread_sync doesn't work with callbacks (in this case not reaching
+ * delete_task_done) we need to set up the undo information ourselves.
+ */
+ g_list_free_full (job->files, g_object_unref);
+
+ if (job->done_callback)
+ {
+ debuting_uris = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);
+ job->done_callback (debuting_uris, job->user_cancel, job->done_callback_data);
+ g_hash_table_unref (debuting_uris);
+ }
+
+ finalize_common ((CommonJob *) job);
+
+ nautilus_file_changes_consume_changes (TRUE);
}
static void
@@ -5887,10 +5903,33 @@ nautilus_file_operations_copy_sync (GList *files,
done_callback,
done_callback_data);
- task = g_task_new (NULL, job->common.cancellable, copy_task_done, job);
+ task = g_task_new (NULL, job->common.cancellable, NULL, job);
g_task_set_task_data (task, job, NULL);
g_task_run_in_thread_sync (task, nautilus_file_operations_copy);
g_object_unref (task);
+ /* Since g_task_run_in_thread_sync doesn't work with callbacks (in this case not reaching
+ * copy_task_done) we need to set up the undo information ourselves.
+ */
+ if (job->done_callback)
+ {
+ job->done_callback (job->debuting_files,
+ !job_aborted ((CommonJob *) job),
+ job->done_callback_data);
+ }
+
+ g_list_free_full (job->files, g_object_unref);
+ if (job->destination)
+ {
+ g_object_unref (job->destination);
+ }
+ g_hash_table_unref (job->debuting_files);
+ g_free (job->target_name);
+
+ g_clear_object (&job->fake_display_source);
+
+ finalize_common ((CommonJob *) job);
+
+ nautilus_file_changes_consume_changes (TRUE);
}
void
@@ -6405,10 +6444,27 @@ nautilus_file_operations_move_sync (GList *files,
CopyMoveJob *job;
job = move_job_setup (files, target_dir, parent_window, done_callback, done_callback_data);
- task = g_task_new (NULL, job->common.cancellable, move_task_done, job);
+ task = g_task_new (NULL, job->common.cancellable, NULL, job);
g_task_set_task_data (task, job, NULL);
g_task_run_in_thread_sync (task, nautilus_file_operations_move);
g_object_unref (task);
+ /* Since g_task_run_in_thread_sync doesn't work with callbacks (in this case not reaching
+ * move_task_done) we need to set up the undo information ourselves.
+ */
+ if (job->done_callback)
+ {
+ job->done_callback (job->debuting_files,
+ !job_aborted ((CommonJob *) job),
+ job->done_callback_data);
+ }
+
+ g_list_free_full (job->files, g_object_unref);
+ g_object_unref (job->destination);
+ g_hash_table_unref (job->debuting_files);
+
+ finalize_common ((CommonJob *) job);
+
+ nautilus_file_changes_consume_changes (TRUE);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]