[Xfce4-commits] <thunar:migration-to-gio> Fix crash in the URI completion of the path entry. Patch by Nick.

Jannis Pohlmann jannis at xfce.org
Fri Aug 21 16:34:01 CEST 2009


Updating branch refs/heads/migration-to-gio
         to abe57845eb7620894a2e4c09769857d16b63d2f1 (commit)
       from 62ad9ea08c84849d6e4384e03f58ec29295c2b5a (commit)

commit abe57845eb7620894a2e4c09769857d16b63d2f1
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Fri Aug 21 16:32:43 2009 +0200

    Fix crash in the URI completion of the path entry. Patch by Nick.

 thunar/thunar-path-entry.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/thunar/thunar-path-entry.c b/thunar/thunar-path-entry.c
index 40d61b6..2946f02 100644
--- a/thunar/thunar-path-entry.c
+++ b/thunar/thunar-path-entry.c
@@ -810,6 +810,12 @@ thunar_path_entry_changed (GtkEditable *editable)
     {
       /* try to parse the URI text */
       file_path = g_file_new_for_uri (text);
+
+      /* use the same file if the text assumes we're in a directory */
+      if (g_str_has_suffix (text, "/"))
+        folder_path = g_object_ref (G_OBJECT (file_path));
+      else
+        folder_path = g_file_get_parent (file_path);
     }
   else if (thunar_path_entry_parse (path_entry, &folder_part, &file_part, NULL))
     {
@@ -831,9 +837,6 @@ thunar_path_entry_changed (GtkEditable *editable)
   current_folder = (folder_path != NULL) ? thunar_file_get (folder_path, NULL) : NULL;
   current_file = (file_path != NULL) ? thunar_file_get (file_path, NULL) : NULL;
 
-  /* TODO Fix bug with non-existent folders */
-  _thunar_assert (current_folder == NULL || thunar_file_is_directory (current_folder));
-
   /* determine the entry completion */
   completion = gtk_entry_get_completion (GTK_ENTRY (path_entry));
 
@@ -848,7 +851,10 @@ thunar_path_entry_changed (GtkEditable *editable)
         g_object_ref (G_OBJECT (current_folder));
 
       /* try to open the current-folder file as folder */
-      folder = (current_folder != NULL) ? thunar_folder_get_for_file (current_folder) : NULL;
+      if (current_folder != NULL && thunar_file_is_directory (current_folder))
+        folder = thunar_folder_get_for_file (current_folder);
+      else
+        folder = NULL;
 
       /* set the new folder for the completion model, but disconnect the model from the
        * completion first, because GtkEntryCompletion has become very slow recently when



More information about the Xfce4-commits mailing list