[nautilus/gnome-2-32] pathbar: use another way to remove buttons (#627901)



commit c92674ae26f149ea446c1d6f9f024d22218463e8
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Sep 17 20:23:34 2010 +0200

    pathbar: use another way to remove buttons (#627901)
    
    This fixes a crasher in _size_allocate() where the list of buttons did
    not contain valid data anymore.

 src/nautilus-pathbar.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 3d64688..a9e7adc 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -1509,7 +1509,7 @@ button_data_file_changed (NautilusFile *file,
 			  ButtonData *button_data)
 {
 	GFile *location, *current_location, *parent, *button_parent;
-	ButtonData *current_button_data, *temp_button_data;
+	ButtonData *current_button_data;
 	char *display_name;
 	NautilusPathBar *path_bar;
 	gboolean renamed, child;
@@ -1569,18 +1569,17 @@ button_data_file_changed (NautilusFile *file,
 			return;
 		}
 	} else if (nautilus_file_is_gone (file)) {
-		/* remove this and the following buttons */
-		GList *children;
-
-		children = g_list_find (path_bar->button_list, button_data);
-
-		while (children != NULL) {
-			temp_button_data = children->data;
+		gint idx, position;
 
-			/* children are in reverse order */
-			children = children->prev;
+		/* remove this and the following buttons */
+		position = g_list_position (path_bar->button_list,
+					    g_list_find (path_bar->button_list, button_data));
 
-			gtk_container_remove (GTK_CONTAINER (path_bar), temp_button_data->button);
+		if (position != -1) {
+			for (idx = 0; idx <= position; idx++) {
+				gtk_container_remove (GTK_CONTAINER (path_bar),
+						      BUTTON_DATA (path_bar->button_list->data)->button);
+			}
 		}
 
 		g_object_unref (location);



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