]> Pileus Git - ~andy/gtk/commitdiff
Don't call button_data_free() explicitly; the button is weak-reffed and
authorFederico Mena Quintero <federico@ximian.com>
Thu, 6 Jan 2005 01:46:39 +0000 (01:46 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Thu, 6 Jan 2005 01:46:39 +0000 (01:46 +0000)
2005-01-05  Federico Mena Quintero  <federico@ximian.com>

* gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call
button_data_free() explicitly; the button is weak-reffed and the
callback will free the button data.  Fixes #163010.
(_gtk_path_bar_set_path): Don't ref/sink the button.  And for the
failure case, call gtk_widget_destroy() on it.

* gtk/gtkfilechooserdefault.c (check_is_folder): Use
gtk_file_system_get_folder() again (see the ChangeLog entry from
2004-08-25).  We can't first get the parent folder and then
request the info for the path in question, as the parent folder
may not be readable.  See bug #162617.
(gtk_file_chooser_default_set_current_folder): Assert that the
passed-in path is not null.
(shortcuts_find_current_folder): Likewise.
(shortcuts_add_current_folder): Likewise.
(set_list_model): Likewise.
(gtk_file_chooser_default_map): Only reload the current folder if
it exists.
(bookmarks_check_add_sensitivity): Check for the current folder
being NULL.
(browse_files_select_first_row): Don't set the cursor if there is
no model loaded.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c
gtk/gtkpathbar.c

index 72d776f7b9c36a342a86ff0842d169ce81e4d42e..40c7d6eada384f6009443d4ce977b8512e3960ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2005-01-05  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call
+       button_data_free() explicitly; the button is weak-reffed and the
+       callback will free the button data.  Fixes #163010.
+       (_gtk_path_bar_set_path): Don't ref/sink the button.  And for the
+       failure case, call gtk_widget_destroy() on it.
+
+       * gtk/gtkfilechooserdefault.c (check_is_folder): Use
+       gtk_file_system_get_folder() again (see the ChangeLog entry from
+       2004-08-25).  We can't first get the parent folder and then
+       request the info for the path in question, as the parent folder
+       may not be readable.  See bug #162617.
+       (gtk_file_chooser_default_set_current_folder): Assert that the
+       passed-in path is not null.
+       (shortcuts_find_current_folder): Likewise.
+       (shortcuts_add_current_folder): Likewise.
+       (set_list_model): Likewise.
+       (gtk_file_chooser_default_map): Only reload the current folder if
+       it exists.
+       (bookmarks_check_add_sensitivity): Check for the current folder
+       being NULL.
+       (browse_files_select_first_row): Don't set the cursor if there is
+       no model loaded.
+
 2005-01-05  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdefault.c: Don't construct errors from 
index 72d776f7b9c36a342a86ff0842d169ce81e4d42e..40c7d6eada384f6009443d4ce977b8512e3960ed 100644 (file)
@@ -1,3 +1,28 @@
+2005-01-05  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call
+       button_data_free() explicitly; the button is weak-reffed and the
+       callback will free the button data.  Fixes #163010.
+       (_gtk_path_bar_set_path): Don't ref/sink the button.  And for the
+       failure case, call gtk_widget_destroy() on it.
+
+       * gtk/gtkfilechooserdefault.c (check_is_folder): Use
+       gtk_file_system_get_folder() again (see the ChangeLog entry from
+       2004-08-25).  We can't first get the parent folder and then
+       request the info for the path in question, as the parent folder
+       may not be readable.  See bug #162617.
+       (gtk_file_chooser_default_set_current_folder): Assert that the
+       passed-in path is not null.
+       (shortcuts_find_current_folder): Likewise.
+       (shortcuts_add_current_folder): Likewise.
+       (set_list_model): Likewise.
+       (gtk_file_chooser_default_map): Only reload the current folder if
+       it exists.
+       (bookmarks_check_add_sensitivity): Check for the current folder
+       being NULL.
+       (browse_files_select_first_row): Don't set the cursor if there is
+       no model loaded.
+
 2005-01-05  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdefault.c: Don't construct errors from 
index 72d776f7b9c36a342a86ff0842d169ce81e4d42e..40c7d6eada384f6009443d4ce977b8512e3960ed 100644 (file)
@@ -1,3 +1,28 @@
+2005-01-05  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call
+       button_data_free() explicitly; the button is weak-reffed and the
+       callback will free the button data.  Fixes #163010.
+       (_gtk_path_bar_set_path): Don't ref/sink the button.  And for the
+       failure case, call gtk_widget_destroy() on it.
+
+       * gtk/gtkfilechooserdefault.c (check_is_folder): Use
+       gtk_file_system_get_folder() again (see the ChangeLog entry from
+       2004-08-25).  We can't first get the parent folder and then
+       request the info for the path in question, as the parent folder
+       may not be readable.  See bug #162617.
+       (gtk_file_chooser_default_set_current_folder): Assert that the
+       passed-in path is not null.
+       (shortcuts_find_current_folder): Likewise.
+       (shortcuts_add_current_folder): Likewise.
+       (set_list_model): Likewise.
+       (gtk_file_chooser_default_map): Only reload the current folder if
+       it exists.
+       (bookmarks_check_add_sensitivity): Check for the current folder
+       being NULL.
+       (browse_files_select_first_row): Don't set the cursor if there is
+       no model loaded.
+
 2005-01-05  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdefault.c: Don't construct errors from 
index 72d776f7b9c36a342a86ff0842d169ce81e4d42e..40c7d6eada384f6009443d4ce977b8512e3960ed 100644 (file)
@@ -1,3 +1,28 @@
+2005-01-05  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call
+       button_data_free() explicitly; the button is weak-reffed and the
+       callback will free the button data.  Fixes #163010.
+       (_gtk_path_bar_set_path): Don't ref/sink the button.  And for the
+       failure case, call gtk_widget_destroy() on it.
+
+       * gtk/gtkfilechooserdefault.c (check_is_folder): Use
+       gtk_file_system_get_folder() again (see the ChangeLog entry from
+       2004-08-25).  We can't first get the parent folder and then
+       request the info for the path in question, as the parent folder
+       may not be readable.  See bug #162617.
+       (gtk_file_chooser_default_set_current_folder): Assert that the
+       passed-in path is not null.
+       (shortcuts_find_current_folder): Likewise.
+       (shortcuts_add_current_folder): Likewise.
+       (set_list_model): Likewise.
+       (gtk_file_chooser_default_map): Only reload the current folder if
+       it exists.
+       (bookmarks_check_add_sensitivity): Check for the current folder
+       being NULL.
+       (browse_files_select_first_row): Don't set the cursor if there is
+       no model loaded.
+
 2005-01-05  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdefault.c: Don't construct errors from 
index bf8722aa4051e1dd277dceba7fcb41640c4be1c1..0baca0b123e984f4ef17fba4c4ad62abb3274940 100644 (file)
@@ -1066,6 +1066,7 @@ shortcuts_find_current_folder (GtkFileChooserDefault *impl)
 
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
 
+  g_assert (impl->current_folder != NULL);
   pos = shortcut_find_position (impl, impl->current_folder);
   if (pos == -1)
     {
@@ -1130,32 +1131,14 @@ check_is_folder (GtkFileSystem      *file_system,
                 const GtkFilePath  *path, 
                 GError            **error)
 {
-  GtkFileInfo *info;
-  gboolean is_folder;
+  GtkFileFolder *folder;
 
-  /* Use get_file_info() rather than trying get_folder() and checking
-   * for an error directly because older versions of the gnome-vfs
-   * backend don't return an error immediately. This way is also
-   * more efficient if we already have the parent folder. 
-   */
-  info = get_file_info (file_system, path, FALSE, error);
-  
-  if (!info)
+  folder = gtk_file_system_get_folder (file_system, path, 0, error);
+  if (!folder)
     return FALSE;
-  
-  is_folder = gtk_file_info_get_is_folder (info);
-
-  if (!is_folder)
-    g_set_error (error,
-                GTK_FILE_CHOOSER_ERROR,
-                GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
-                "%s: %s", 
-                gtk_file_info_get_display_name (info),
-                g_strerror (ENOTDIR));
-
-  gtk_file_info_free (info);
 
-  return is_folder;
+  g_object_unref (folder);
+  return TRUE;
 }
 
 /* Inserts a path in the shortcuts tree, making a copy of it; alternatively,
@@ -1503,6 +1486,8 @@ shortcuts_add_current_folder (GtkFileChooserDefault *impl)
 
   success = TRUE;
 
+  g_assert (impl->current_folder != NULL);
+
   pos = shortcut_find_position (impl, impl->current_folder);
   if (pos == -1)
     {
@@ -2128,7 +2113,7 @@ bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl)
   selection_check (impl, &num_selected, NULL, &all_folders);
 
   if (num_selected == 0)
-    active = (shortcut_find_position (impl, impl->current_folder) == -1);
+    active = (impl->current_folder != NULL) && (shortcut_find_position (impl, impl->current_folder) == -1);
   else if (num_selected == 1)
     {
       const GtkFilePath *path;
@@ -4092,7 +4077,9 @@ gtk_file_chooser_default_map (GtkWidget *widget)
 
   GTK_WIDGET_CLASS (parent_class)->map (widget);
 
-  change_folder_and_display_error (impl, impl->current_folder);
+  if (impl->current_folder)
+    change_folder_and_display_error (impl, impl->current_folder);
+
   bookmarks_changed_cb (impl->file_system, impl);
 }
 
@@ -4345,6 +4332,9 @@ browse_files_select_first_row (GtkFileChooserDefault *impl)
 {
   GtkTreePath *path;
 
+  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);
   gtk_tree_path_free (path);
@@ -4429,6 +4419,8 @@ static gboolean
 set_list_model (GtkFileChooserDefault *impl,
                GError               **error)
 {
+  g_assert (impl->current_folder != NULL);
+
   load_remove_timer (impl);
 
   if (impl->browse_files_model)
@@ -4504,6 +4496,8 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser    *chooser,
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
   gboolean result;
 
+  g_assert (path != NULL);
+
   if (impl->local_only &&
       !gtk_file_system_path_is_local (impl->file_system, path))
     {
index fdc29b391fe8a17a96a9233c6e7df9aafefb72ed..4de2da197bc16ffdeffb623bd3d500ba2771daf1 100644 (file)
@@ -1294,9 +1294,6 @@ _gtk_path_bar_set_path (GtkPathBar         *path_bar,
       gtk_file_info_free (file_info);
       gtk_file_path_free (path);
 
-      g_object_ref (button_data->button);
-      gtk_object_sink (GTK_OBJECT (button_data->button));
-
       new_buttons = g_list_prepend (new_buttons, button_data);
 
       if (button_data->type != NORMAL_BUTTON)
@@ -1331,9 +1328,7 @@ _gtk_path_bar_set_path (GtkPathBar         *path_bar,
          ButtonData *button_data;
 
          button_data = BUTTON_DATA (l->data);
-
-         gtk_widget_unref (button_data->button);
-         button_data_free (button_data);
+         gtk_widget_destroy (button_data->button);
        }
 
       g_list_free (new_buttons);