[nautilus] window-manage-views: don't call methods on a NULL NautilusFile



commit 270ffdfa13ff0f49639abc8c0d6cfd75415b96cc
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue May 8 17:01:21 2012 -0400

    window-manage-views: don't call methods on a NULL NautilusFile
    
    In got_file_info_for_view_selection_callback(), we unconditionally try
    to fetch information for the parent directory in case the selection is a
    regular file, but we should avoid doing that when the file has no
    parent, such as when it's the root of a web server.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675259

 src/nautilus-window-manage-views.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 7e42f46..ac84a4e 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -766,7 +766,7 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
 	char *mimetype;
 	NautilusWindow *window;
 	NautilusWindowSlot *slot;
-	NautilusFile *viewed_file;
+	NautilusFile *viewed_file, *parent_file;
 	GFile *location;
 	GMountOperation *mount_op;
 	MountNotMountedData *data;
@@ -805,7 +805,9 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
 		return;
 	}
 
-	if (nautilus_file_get_file_type (file) == G_FILE_TYPE_REGULAR) {
+	parent_file = nautilus_file_get_parent (file);
+	if ((parent_file != NULL) &&
+	    nautilus_file_get_file_type (file) == G_FILE_TYPE_REGULAR) {
 		if (slot->pending_selection != NULL) {
 			g_list_free_full (slot->pending_selection, (GDestroyNotify) nautilus_file_unref);
 		}
@@ -815,7 +817,7 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
 	
 		slot->pending_location = nautilus_file_get_parent_location (file);
 		slot->pending_selection = g_list_prepend (NULL, nautilus_file_ref (file));
-		slot->determine_view_file = nautilus_file_get_parent (file);
+		slot->determine_view_file = parent_file;
 		slot->pending_scroll_to = nautilus_file_get_uri (file);
 
 		nautilus_file_invalidate_all_attributes (slot->determine_view_file);
@@ -829,6 +831,7 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
 		return;
 	}
 
+	nautilus_file_unref (parent_file);
 	location = slot->pending_location;
 	
 	view_id = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]