Re: nautilus crashes on upgrade fc2->fc3 in gnome 2.8



On Fri, 2004-12-03 at 16:18 +0100, Alexander Larsson wrote:
> On Tue, 2004-11-30 at 21:20 +0100, Martin Wehner wrote:
> > On Mon, 2004-11-22 at 23:21 +0100, Martin Wehner wrote:
> > > On Mon, 2004-11-22 at 22:40 +0100, Martin Wehner wrote:
> > > > /* We try to use the drive name to get somewhat stable filenames
> > > >    for metadata */
> > > > drive = gnome_vfs_volume_get_drive (volume);
> > > > if (drive != NULL) {
> > > > 	name = gnome_vfs_drive_get_display_name (drive);
> > > > } else {
> > > > 	name = gnome_vfs_volume_get_display_name (volume);
> > > > }
> > > > gnome_vfs_drive_unref (drive);
> > > > link->details->filename = g_strconcat (name, ".volume", NULL);
> > > 
> > > It looks like it wouldn't work for two volumes on the same drive
> > > either.. What does using the disk name buy you here?
> > 
> > Alex,
> > 
> > could you have a look at this? With 24 duplicates, it's the undisputed
> > top crasher of the 2.8.x series.
> > I'd say let's remove the usage of the drive name altogether, because
> > you'd have to jump through hoops to guarantee the uniqueness of the
> > desktop link filename at this point.
> > What do you think?
> 
> The thing is, the name is used for metadata storage, such as the
> positions of the icon on the desktop, emblems and whatnot. Using the
> disk name instead of the volume name means the position of e.g. the
> cdrom icon is always the same, even if you switch cds in the drive.
> 
> I'm not sure whats the best thing to do here. Just try to uniquify the
> name if we already have a desktop icon with that name?

What about something like this (untested)? (I didn't get it to reproduce
atm.)

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a jaded ninja assassin haunted by an iconic dead American confidante 
She's a sarcastic paranoid fairy princess in the wrong place at the wrong 
time. They fight crime! 
Index: libnautilus-private/nautilus-desktop-link-monitor.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-link-monitor.c,v
retrieving revision 1.10
diff -u -p -r1.10 nautilus-desktop-link-monitor.c
--- libnautilus-private/nautilus-desktop-link-monitor.c	14 May 2004 09:34:07 -0000	1.10
+++ libnautilus-private/nautilus-desktop-link-monitor.c	3 Dec 2004 15:57:45 -0000
@@ -111,11 +111,34 @@ nautilus_desktop_link_monitor_delete_lin
 	}
 }
 
+static gboolean
+volume_file_name_used (NautilusDesktopLinkMonitor *monitor,
+		       const char *name)
+{
+	GList *l;
+	char *other_name;
+	gboolean same;
+
+	for (l = monitor->details->volume_links; l != NULL; l = l->next) {
+		other_name = nautilus_desktop_link_get_file_name (l->data);
+		same = strcmp (name, other_name) == 0;
+		g_free (other_name);
+
+		if (same) {
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
 static void
 create_volume_link (NautilusDesktopLinkMonitor *monitor,
 		    GnomeVFSVolume *volume)
 {
 	NautilusDesktopLink *link;
+	char *orig_name, *new_name;
+	int i;
 
 	link = NULL;
 
@@ -125,6 +148,23 @@ create_volume_link (NautilusDesktopLinkM
 
 	if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE)) {
 		link = nautilus_desktop_link_new_from_volume (volume);
+		orig_name = nautilus_desktop_link_get_file_name (link);
+
+		if (volume_file_name_used (monitor, orig_name)) {
+			i = 2;
+			new_name = NULL;
+			do {
+				g_free (new_name);
+				new_name = g_strdup_printf ("%s.%d", orig_name, i++);
+			} while (volume_file_name_used (monitor, new_name));
+
+			nautilus_desktop_link_set_filename (link,
+							    new_name);
+			g_free (new_name);
+		}
+		
+		g_free (orig_name);
+		
 		monitor->details->volume_links = g_list_prepend (monitor->details->volume_links, link);
 	}
 	
Index: libnautilus-private/nautilus-desktop-link.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-link.c,v
retrieving revision 1.9
diff -u -p -r1.9 nautilus-desktop-link.c
--- libnautilus-private/nautilus-desktop-link.c	22 Nov 2004 15:24:35 -0000	1.9
+++ libnautilus-private/nautilus-desktop-link.c	3 Dec 2004 15:57:45 -0000
@@ -238,6 +238,15 @@ nautilus_desktop_link_get_file_name (Nau
 	return g_strdup (link->details->filename);
 }
 
+void
+nautilus_desktop_link_set_filename (NautilusDesktopLink     *link,
+				    const char              *name)
+{
+	g_free (link->details->filename);
+	link->details->filename = g_strdup (name);
+}
+
+
 char *
 nautilus_desktop_link_get_display_name (NautilusDesktopLink *link)
 {
Index: libnautilus-private/nautilus-desktop-link.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-link.h,v
retrieving revision 1.3
diff -u -p -r1.3 nautilus-desktop-link.h
--- libnautilus-private/nautilus-desktop-link.h	6 Nov 2003 16:07:01 -0000	1.3
+++ libnautilus-private/nautilus-desktop-link.h	3 Dec 2004 15:57:45 -0000
@@ -75,4 +75,8 @@ gboolean                nautilus_desktop
 gboolean                nautilus_desktop_link_rename             (NautilusDesktopLink     *link,
 								  const char              *name);
 
+/* Used to uniquify the filename */
+void                    nautilus_desktop_link_set_filename       (NautilusDesktopLink     *link,
+								  const char              *name);
+
 #endif /* NAUTILUS_DESKTOP_LINK_H */


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