diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-01-30 10:01:57 -0500 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-01-30 10:01:57 -0500 |
commit | 2a02b02328e20ac66b8cb71140681fdd0ac384ff (patch) | |
tree | cc964bf415495e17715fee7243e18fed727bb214 | |
parent | 2944be953ef54717bb24968b0eebe468c9705db4 (diff) | |
download | nautilus-2a02b02328e20ac66b8cb71140681fdd0ac384ff.tar.gz |
undo: make sure to correctly clear the undo state on operation finish
Don't stack allocate the struct for the file operations return value,
and make sure we don't return success for a failed operation.
-rw-r--r-- | libnautilus-private/nautilus-file-undo-operations.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/libnautilus-private/nautilus-file-undo-operations.c b/libnautilus-private/nautilus-file-undo-operations.c index a3caef77f..4a17cd3cc 100644 --- a/libnautilus-private/nautilus-file-undo-operations.c +++ b/libnautilus-private/nautilus-file-undo-operations.c @@ -226,6 +226,12 @@ typedef struct { gboolean user_cancel; } FileUndoInfoOpRes; +static void +file_undo_info_op_res_free (gpointer data) +{ + g_slice_free (FileUndoInfoOpRes, data); +} + gboolean nautilus_file_undo_info_apply_finish (NautilusFileUndoInfo *self, GAsyncResult *res, @@ -261,12 +267,14 @@ file_undo_info_complete_apply (NautilusFileUndoInfo *self, gboolean success, gboolean user_cancel) { - FileUndoInfoOpRes op_res; + FileUndoInfoOpRes *op_res = g_slice_new0 (FileUndoInfoOpRes); - op_res.user_cancel = user_cancel; - op_res.success = success; + op_res->user_cancel = user_cancel; + op_res->success = success; - g_simple_async_result_set_op_res_gpointer (self->priv->apply_async_result, &op_res, NULL); + + g_simple_async_result_set_op_res_gpointer (self->priv->apply_async_result, op_res, + file_undo_info_op_res_free); g_simple_async_result_complete_in_idle (self->priv->apply_async_result); g_clear_object (&self->priv->apply_async_result); @@ -1113,14 +1121,17 @@ trash_retrieve_files_ready (GObject *source, } g_list_free (gfiles_in_trash); + + /* Here we must do what's necessary for the callback */ + file_undo_info_transfer_callback (NULL, (error == NULL), self); + } else { + file_undo_info_transfer_callback (NULL, FALSE, self); } if (files_to_restore != NULL) { g_hash_table_destroy (files_to_restore); } - /* Here we must do what's necessary for the callback */ - file_undo_info_transfer_callback (NULL, (error != NULL), self); g_clear_error (&error); } |