Nautilus patch



Hi,

The attached patch fixes some serious issues with the nautilus trash 
volume handling. Without this you are unable to unmount removable media if 
you have fam enabled. It also fixes possible reads of freed memory.

Is this ok to check in to Nautilus?

If not, We don't need to do a release today since there has been no other 
changes since the last one. 

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's an all-American bohemian dog-catcher trapped in a world he never made. 
She's a cynical Bolivian college professor with an MBA from Harvard. They 
fight crime! 
Index: libnautilus-private/nautilus-trash-directory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-trash-directory.c,v
retrieving revision 1.33
diff -u -p -r1.33 nautilus-trash-directory.c
--- libnautilus-private/nautilus-trash-directory.c	7 Mar 2002 19:36:02 -0000	1.33
+++ libnautilus-private/nautilus-trash-directory.c	28 Aug 2002 13:53:23 -0000
@@ -136,6 +136,7 @@ get_trash_volume (NautilusTrashDirectory
 		  GnomeVFSURI **volume_mount_uri)
 {
 	char *uri_str;
+	NautilusVolume *volume_copy;
 
 	/* Quick out if we already know about this volume. */
 	*trash_volume = g_hash_table_lookup (trash->details->volumes,
@@ -157,8 +158,9 @@ get_trash_volume (NautilusTrashDirectory
 		/* Make the structure used to track the trash for this volume. */
 		*trash_volume = g_new0 (TrashVolume, 1);
 		(*trash_volume)->trash = trash;
-		(*trash_volume)->volume = volume;
-		g_hash_table_insert (trash->details->volumes, volume, *trash_volume);
+		volume_copy = nautilus_volume_copy (volume);
+		(*trash_volume)->volume = volume_copy;
+		g_hash_table_insert (trash->details->volumes, volume_copy, *trash_volume);
 	}
 	
 	return TRUE;
@@ -250,6 +252,7 @@ remove_trash_volume (TrashVolume *trash_
 		}
 		nautilus_directory_unref (trash_volume->real_directory);
 	}
+	nautilus_volume_free (trash_volume->volume);
 	g_free (trash_volume);
 }
 
@@ -306,7 +309,8 @@ nautilus_trash_directory_instance_init (
 	NautilusVolumeMonitor *volume_monitor;
 
 	trash->details = g_new0 (NautilusTrashDirectoryDetails, 1);
-	trash->details->volumes = g_hash_table_new (NULL, NULL);
+	trash->details->volumes = g_hash_table_new ((GHashFunc)nautilus_volume_hash,
+						    (GEqualFunc)nautilus_volume_is_equal);
 
 	volume_monitor = nautilus_volume_monitor_get ();
 
Index: libnautilus-private/nautilus-volume-monitor.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-volume-monitor.c,v
retrieving revision 1.133
diff -u -p -r1.133 nautilus-volume-monitor.c
--- libnautilus-private/nautilus-volume-monitor.c	11 Jul 2002 17:11:51 -0000	1.133
+++ libnautilus-private/nautilus-volume-monitor.c	28 Aug 2002 13:53:23 -0000
@@ -213,7 +213,6 @@ static GList *         finish_creating_v
 								 NautilusVolume             *volume,
 								 const char                 *file_system_type_name,
 								 GList                      *volume_list);
-static NautilusVolume *copy_volume                              (const NautilusVolume       *volume);
 static void            find_volumes                             (NautilusVolumeMonitor      *monitor);
 static void            free_mount_list                          (GList                      *mount_list);
 static GList *         copy_mount_list                          (GList                      *mount_list);
@@ -221,7 +220,6 @@ static GList *         get_removable_vol
 static GHashTable *    create_readable_mount_point_name_table   (void);
 static int             get_cdrom_type                           (const char                 *vol_dev_path,
 								 int                        *fd);
-static void            nautilus_volume_free                     (NautilusVolume             *volume);
 static void            nautilus_file_system_type_free           (NautilusFileSystemType     *type);
 static gboolean        entry_is_supermounted_volume             (const MountTableEntry *ent, 
 								 const NautilusVolume *volume);
@@ -768,6 +766,26 @@ nautilus_volume_get_device_type (const N
 	return volume->device_type;
 }
 
+gboolean
+nautilus_volume_is_equal (const NautilusVolume       *volume1,
+			  const NautilusVolume       *volume2)
+{
+	if (strcmp (volume1->mount_path, volume2->mount_path) != 0) {
+		return FALSE;
+	}
+	if (strcmp (volume1->device_path, volume2->device_path) != 0) {
+		return FALSE;
+	}
+	
+	return TRUE;
+}
+
+guint
+nautilus_volume_hash (const NautilusVolume       *volume)
+{
+	return g_str_hash (volume->mount_path);
+}
+
 
 /* create_readable_mount_point_name_table
  *
@@ -898,7 +916,7 @@ copy_mount_list (GList *mount_list)
 	while (list) {
 		volume = list->data;
 
-		new_list = g_list_prepend (new_list, copy_volume (volume));
+		new_list = g_list_prepend (new_list, nautilus_volume_copy (volume));
 				
 		list = list->next;
 	}
@@ -935,7 +953,7 @@ build_volume_list_delta (GList *list_one
 		
 		if (!found_match) {
 			/* No match. Add it to the list to be returned; */
-			new_volume = copy_volume (volOne);
+			new_volume = nautilus_volume_copy (volOne);
 			new_list = g_list_prepend (new_list, new_volume);
 		}
 	}
@@ -1684,8 +1702,8 @@ create_volume (const char *device_path, 
 	return volume;
 }
 
-static NautilusVolume *
-copy_volume (const NautilusVolume *volume)
+NautilusVolume *
+nautilus_volume_copy (const NautilusVolume *volume)
 {
 	NautilusVolume *new_volume;
 
Index: libnautilus-private/nautilus-volume-monitor.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-volume-monitor.h,v
retrieving revision 1.38
diff -u -p -r1.38 nautilus-volume-monitor.h
--- libnautilus-private/nautilus-volume-monitor.h	28 Jun 2002 10:59:07 -0000	1.38
+++ libnautilus-private/nautilus-volume-monitor.h	28 Aug 2002 13:53:23 -0000
@@ -104,4 +104,11 @@ const char *             nautilus_volume
 char *                   nautilus_volume_get_target_uri                     (const NautilusVolume       *volume);
 const char *             nautilus_volume_get_device_path                    (NautilusVolume             *volume);
 
+NautilusVolume *         nautilus_volume_copy                               (const NautilusVolume       *volume);
+void                     nautilus_volume_free                               (NautilusVolume             *volume);
+guint                    nautilus_volume_hash                               (const NautilusVolume       *volume);
+gboolean                 nautilus_volume_is_equal                           (const NautilusVolume       *volume1,
+									     const NautilusVolume       *volume2);
+
+
 #endif /* NAUTILUS_VOLUME_MONITOR_H */


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