[gtksourceview] FileSaver: g_task_return for all valid cases



commit 4e180c87b8dc68be6561f88383c25deea10a6932
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat May 7 11:14:26 2016 +0200

    FileSaver: g_task_return for all valid cases
    
    That way, the GAsyncReadyCallback is always called (in valid cases), so
    the code using a FileSaver can continue its execution.

 gtksourceview/gtksourcefilesaver.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gtksourceview/gtksourcefilesaver.c b/gtksourceview/gtksourcefilesaver.c
index 84d24c1..83942af 100644
--- a/gtksourceview/gtksourcefilesaver.c
+++ b/gtksourceview/gtksourcefilesaver.c
@@ -1323,13 +1323,6 @@ gtk_source_file_saver_save_async (GtkSourceFileSaver     *saver,
        g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
        g_return_if_fail (saver->priv->task == NULL);
 
-       if (saver->priv->source_buffer == NULL ||
-           saver->priv->file == NULL ||
-           saver->priv->location == NULL)
-       {
-               return;
-       }
-
        reset (saver);
 
        saver->priv->task = g_task_new (saver, cancellable, callback, user_data);
@@ -1339,6 +1332,14 @@ gtk_source_file_saver_save_async (GtkSourceFileSaver     *saver,
        saver->priv->progress_cb_data = progress_callback_data;
        saver->priv->progress_cb_notify = progress_callback_notify;
 
+       if (saver->priv->source_buffer == NULL ||
+           saver->priv->file == NULL ||
+           saver->priv->location == NULL)
+       {
+               g_task_return_boolean (saver->priv->task, FALSE);
+               return;
+       }
+
        check_invalid_chars = (saver->priv->flags & GTK_SOURCE_FILE_SAVER_FLAGS_IGNORE_INVALID_CHARS) == 0;
 
        if (check_invalid_chars && _gtk_source_buffer_has_invalid_chars (saver->priv->source_buffer))


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