[nautilus] Fix rename cancellation



commit 1009c22ee4e633044312f7a21499a422e91cf0be
Author: Tomas Bzatek <tbzatek redhat com>
Date:   Fri Jun 15 18:22:22 2012 +0200

    Fix rename cancellation
    
    This changes the way the wait dialog cancellation callback works. Instead of
    cleaning up early we just cancel the operation and wait for proper
    rename_callback() carrying the error.
    
    This fixes an assertion failure when the wait dialog has been displayed and user
    pressed the Cancel button. Unlikely to happen, found during gvfs testing.

 src/nautilus-error-reporting.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-error-reporting.c b/src/nautilus-error-reporting.c
index db67dd6..b6a162d 100644
--- a/src/nautilus-error-reporting.c
+++ b/src/nautilus-error-reporting.c
@@ -264,6 +264,7 @@ rename_callback (NautilusFile *file, GFile *result_location,
 		 GError *error, gpointer callback_data)
 {
 	NautilusRenameData *data;
+	gboolean cancelled = FALSE;
 
 	g_assert (NAUTILUS_IS_FILE (file));
 	g_assert (callback_data == NULL);
@@ -271,23 +272,22 @@ rename_callback (NautilusFile *file, GFile *result_location,
 	data = g_object_get_data (G_OBJECT (file), NEW_NAME_TAG);
 	g_assert (data != NULL);
 
-	if (error &&
-	    !(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)) {
+	if (error) {
+	  if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)) {
 		/* If rename failed, notify the user. */
 		nautilus_report_error_renaming_file (file, data->name, error, NULL);
+	  } else {
+		cancelled = TRUE;
+	  }
 	}
 
-	finish_rename (file, TRUE, error);
+	finish_rename (file, ! cancelled, error);
 }
 
 static void
 cancel_rename_callback (gpointer callback_data)
 {
-	GError *error;
-	
-	error = g_error_new (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
-	finish_rename (NAUTILUS_FILE (callback_data), FALSE, error);
-	g_error_free (error);
+	nautilus_file_cancel (NAUTILUS_FILE (callback_data), rename_callback, NULL);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]