]> Pileus Git - ~andy/gtk/commitdiff
Don't select the first row if the folder is empty. Patch by Olle
authorMatthias Clasen <matthiasc@src.gnome.org>
Thu, 3 Jul 2008 22:40:33 +0000 (22:40 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 3 Jul 2008 22:40:33 +0000 (22:40 +0000)
        * gtk/gtkfilechooserdefault.c (browse_files_select_first_row): Don't
        select the first row if the folder is empty.
        Patch by Olle Bergkvist.

svn path=/trunk/; revision=20751

ChangeLog
gtk/gtkfilechooserdefault.c

index 997a173a4e3481370a8392286ae74bad41fe67f9..2b9cb36956ff3bce6fbd36fe5974843a8065acf1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,14 @@
        * gdk/win32/gdkinput-win32.c: Fetch the device and cursor names in
        Unicode, and convert to UTF-8 for the GdkDevice's name field.
 
+2008-07-03  Matthias Clasen  <mclasen@redhat.com>
+
+       Bug 538863 – Fixes assertion on entering empty folder
+
+       * gtk/gtkfilechooserdefault.c (browse_files_select_first_row): Don't
+       select the first row if the folder is empty.
+       Patch by Olle Bergkvist.
+
 2008-07-03  Matthias Clasen  <mclasen@redhat.com>
 
        Bug 540915 – GtkBuilder sets properties in reverse order
index ce575eae6c4ad063354c0c4f53804c727a39f6d4..458bdee71ac1a4244643f7c0030d09f756114ca6 100644 (file)
@@ -6285,12 +6285,19 @@ static void
 browse_files_select_first_row (GtkFileChooserDefault *impl)
 {
   GtkTreePath *path;
+  GtkTreeIter dummy_iter;
+  GtkTreeModel *tree_model;
 
   if (!impl->sort_model)
     return;
 
   path = gtk_tree_path_new_from_indices (0, -1);
-  gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), path, NULL, FALSE);
+  tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (impl->browse_files_tree_view));
+
+  /* If the list is empty, do nothing. */
+  if (gtk_tree_model_get_iter (tree_model, &dummy_iter, path))
+      gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), path, NULL, FALSE);
+
   gtk_tree_path_free (path);
 }