[gnome-font-viewer] font-view: Properly complete GTask on errors



commit b64e5bf3092e34bc9c57e2a4d68e5b2e06cdc042
Author: Diego Escalante Urrelo <diegoe gnome org>
Date:   Sun May 3 00:25:51 2020 -0500

    font-view: Properly complete GTask on errors
    
    The GTaskThreadFunc set on g_task_run_in_thread for a task has to
    "complete" the task with a g_task_return_*() function, otherwise you
    can't g_task_propagate_*() on the GAsyncReadyCallback set on
    g_task_new().
    
    This was visible as a GLib-GIO-CRITICAL:
      g_task_propagate_pointer: assertion 'task->result_set' failed
    
    Which was triggered when bluntly returning from the function when a font
    files had no thumbnail and consequently was reporting
    G_FILE_ATTRIBUTE_THUMBNAILING_FAILED.
    
    Signed-off-by: Christopher Davis <christopherdavis gnome org>

 src/font-view.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/font-view.c b/src/font-view.c
index da92553..9980e28 100644
--- a/src/font-view.c
+++ b/src/font-view.c
@@ -261,12 +261,15 @@ font_view_item_load_thumbnail_job (GTask *task,
 
         if (error != NULL) {
             g_debug ("Can't query info for file %s: %s", file_uri, error->message);
+            g_task_return_error (task, g_steal_pointer(&error));
             return;
         }
 
         thumb_failed = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
-        if (thumb_failed)
+        if (thumb_failed) {
+            g_task_return_pointer (task, NULL, NULL);
             return;
+        }
 
         thumb_path = g_strdup (g_file_info_get_attribute_byte_string (info, 
G_FILE_ATTRIBUTE_THUMBNAIL_PATH));
     } else {
@@ -297,6 +300,7 @@ font_view_item_load_thumbnail_job (GTask *task,
 
         if (error != NULL) {
             g_debug ("Can't read file %s: %s", thumb_path, error->message);
+            g_task_return_error (task, g_steal_pointer(&error));
             return;
         }
 
@@ -307,6 +311,7 @@ font_view_item_load_thumbnail_job (GTask *task,
 
         if (error != NULL) {
             g_debug ("Can't read thumbnail pixbuf %s: %s", thumb_path, error->message);
+            g_task_return_error (task, g_steal_pointer(&error));
             return;
         }
     } else {


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