filesystemmodel: Fix a possible problem
authorMatthias Clasen <mclasen@redhat.com>
Wed, 12 Oct 2022 03:32:35 +0000 (23:32 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 21 Oct 2022 02:34:40 +0000 (22:34 -0400)
If the async query fails to reproduce a file info,
we still need to thaw the model, otherwise it ends
up frozen forever.

This was deduced by reading the code, I haven't
actually seen it happen.

gtk/gtkfilesystemmodel.c

index 87cd5d4ca0a274399f99a7d6fe3aad33f61400fe..d937f23f29dca8ed2e36ba7c3f46e053a6ea1615 100644 (file)
@@ -607,22 +607,19 @@ query_done_helper (GObject *     object,
                    gpointer      data,
                    gboolean      do_thaw_updates)
 {
-  GtkFileSystemModel *model;
+  GtkFileSystemModel *model = GTK_FILE_SYSTEM_MODEL (data);
   GFile *file = G_FILE (object);
   GFileInfo *info;
 
   info = g_file_query_info_finish (file, res, NULL);
-  if (info == NULL)
-    return;
-
-  model = GTK_FILE_SYSTEM_MODEL (data);
-
-  _gtk_file_system_model_update_file (model, file, info);
+  if (info)
+    {
+      _gtk_file_system_model_update_file (model, file, info);
+      g_object_unref (info);
+    }
 
   if (do_thaw_updates)
     thaw_updates (model);
-
-  g_object_unref (info);
 }
 
 static void