From 1582ab697eee39c135db5e985effaa34447c6ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= Date: Sat, 9 Oct 2021 22:35:28 +0100 Subject: file-operations: Simplify abort_job Make finalize_common() call nautilus_file_undo_manager_set_action() only if the job hasn't been cancelled. This way, abort_job() becomes a simple wrapper for g_cancellable_cancel(), and we can just call g_cancellable_cancel() as well if needed (such as from another file). --- src/nautilus-file-operations.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c index 7fd681822..a532c2524 100644 --- a/src/nautilus-file-operations.c +++ b/src/nautilus-file-operations.c @@ -269,6 +269,8 @@ is_all_button_text (const char *button_text) !strcmp (button_text, MERGE_ALL); } +static gboolean job_aborted (CommonJob *job); + static void scan_sources (GList *files, SourceInfo *source_info, CommonJob *job, @@ -1119,7 +1121,10 @@ finalize_common (CommonJob *common) if (common->undo_info != NULL) { - nautilus_file_undo_manager_set_action (common->undo_info); + if (!job_aborted (common)) + { + nautilus_file_undo_manager_set_action (common->undo_info); + } g_object_unref (common->undo_info); } @@ -1619,9 +1624,6 @@ inhibit_power_manager (CommonJob *job, static void abort_job (CommonJob *job) { - /* destroy the undo action data too */ - g_clear_object (&job->undo_info); - g_cancellable_cancel (job->cancellable); } -- cgit v1.2.1