GtkFileChooserWidget: check for empty instead of NULL GListModel
authorLuca Bacci <luca.bacci982@gmail.com>
Sun, 1 May 2022 14:31:47 +0000 (16:31 +0200)
committerLuca Bacci <luca.bacci982@gmail.com>
Sun, 1 May 2022 14:52:13 +0000 (16:52 +0200)
While porting GtkFileChooserWidget from GList to GListModel we did not
change some checks for NULL to checks for empty list.

Fixes #4851, #4858

gtk/gtkfilechooserwidget.c

index be084da4212260d140d5a4744c1e59dbd4eee6c1..4c34c498408fa99fa1f89df59e7bf7ce97a142b0 100644 (file)
@@ -5448,7 +5448,7 @@ gtk_file_chooser_widget_get_files (GtkFileChooser *chooser)
        * So we want the selection to be "bar/foo.txt".  Jump to the case for the
        * filename entry to see if that is the case.
        */
-      if (info.result == NULL && impl->location_entry)
+      if (g_list_model_get_n_items (G_LIST_MODEL (info.result)) == 0 && impl->location_entry)
         goto file_entry;
     }
   else if (impl->location_entry &&
@@ -5497,7 +5497,7 @@ gtk_file_chooser_widget_get_files (GtkFileChooser *chooser)
    * then we fall back to the current directory
    */
   if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER &&
-      info.result == NULL)
+      g_list_model_get_n_items (G_LIST_MODEL (info.result)) == 0)
     {
       GFile *current_folder;