--- gnome-vfs-mime-info-cache.c.orig	2004-11-29 13:43:20.000000000 +0100
+++ gnome-vfs-mime-info-cache.c	2004-11-29 13:46:02.000000000 +0100
@@ -780,38 +780,52 @@
 	gchar *desktop_entry;
 	char **desktop_entries;
 	GList *dir_list;
+	GList *mime_types, *m_list;
 	GnomeVFSMimeInfoCacheDir *dir;
 	int i;
+	char *type;
 
 	gnome_vfs_mime_info_cache_init ();
 
 	G_LOCK (mime_info_cache);
-
-	desktop_entry = g_hash_table_lookup (mime_info_cache->global_defaults_cache,
-					     mime_type);
-	if (desktop_entry) {
-		G_UNLOCK (mime_info_cache);
-		return g_strdup (desktop_entry);
-	}
+	mime_types = get_all_parent_types (mime_type);
 
 	desktop_entry = NULL;
-	for (dir_list = mime_info_cache->dirs; dir_list != NULL; dir_list = dir_list->next) {
-		dir = dir_list->data;
-		desktop_entries = g_hash_table_lookup (dir->defaults_list_map,
-						       mime_type);
-		for (i = 0; desktop_entries != NULL && desktop_entries[i] != NULL; i++) {
-			desktop_entry = desktop_entries[i];
-			if (desktop_entry != NULL &&
-			    gnome_vfs_mime_info_desktop_entry_is_valid (desktop_entry)) {
-				g_hash_table_insert (mime_info_cache->global_defaults_cache,
-						     g_strdup (mime_type), g_strdup (desktop_entry));
-				G_UNLOCK (mime_info_cache);
-				return g_strdup (desktop_entry);
+	for (m_list = mime_types; m_list != NULL; m_list = m_list->next) {
+		type = m_list->data;
+		desktop_entry = g_hash_table_lookup (mime_info_cache->global_defaults_cache,
+						     type);
+		if (desktop_entry) {
+			goto cleanup;
+		}
+
+		for (dir_list = mime_info_cache->dirs; dir_list != NULL;
+		     dir_list = dir_list->next) {
+			dir = dir_list->data;
+			desktop_entries = g_hash_table_lookup (dir->defaults_list_map,
+							       type);
+			for (i = 0; desktop_entries != NULL && desktop_entries[i] != NULL; i++) {
+				desktop_entry = desktop_entries[i];
+				if (desktop_entry != NULL &&
+				    gnome_vfs_mime_info_desktop_entry_is_valid (desktop_entry)) {
+					g_hash_table_insert (mime_info_cache->global_defaults_cache,
+							     g_strdup (type),
+							     g_strdup (desktop_entry));
+					goto cleanup;
+				}
 			}
 		}
 	}
+
+ cleanup:
 	G_UNLOCK (mime_info_cache);
 
+	g_list_foreach (mime_types, (GFunc)g_free, NULL);
+	g_list_free (mime_types);
+
+	if (desktop_entry) {
+		return g_strdup (desktop_entry);
+	}
 	return NULL;
 }
 
