summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2001-01-03 00:03:24 +0000
committerDarin Adler <darin@src.gnome.org>2001-01-03 00:03:24 +0000
commit0f3e5e583e6b8ebc1e981955d7e2ea63659a144e (patch)
tree8881ced9064a7806fc38cf984e53c22f6066557f
parent6b4c9532027968459641201077d41552d0b8e90c (diff)
downloadnautilus-0f3e5e583e6b8ebc1e981955d7e2ea63659a144e.tar.gz
reviewed by: John Sullivan <sullivan@eazel.com>
Fixed bug 4344 (assertion if you view a directory without a metafile). * libnautilus-extensions/nautilus-directory.c: (nautilus_directory_initialize), (nautilus_directory_destroy): Create and destroy the metafile hash table when the directory is created and destroyed instead of waiting until the metafile is read. * libnautilus-extensions/nautilus-directory-metafile.c: (get_file_node): Get rid of code to handle NULL for hash table. (nautilus_directory_metafile_destroy): Just destroy the contents of the hash table (hash table itself is destroyed elsewhere now). (nautilus_directory_rename_file_metadata), (nautilus_directory_remove_file_metadata): Get rid of code to handle NULL for the hash table. (nautilus_directory_set_metafile_contents): Don't create the hash table any more, just populate it.
-rw-r--r--ChangeLog23
-rw-r--r--libnautilus-extensions/nautilus-directory-metafile.c55
-rw-r--r--libnautilus-extensions/nautilus-directory.c13
-rw-r--r--libnautilus-private/nautilus-directory-metafile.c55
-rw-r--r--libnautilus-private/nautilus-directory.c13
5 files changed, 85 insertions, 74 deletions
diff --git a/ChangeLog b/ChangeLog
index f6d601e45..85b16a2da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,29 @@
reviewed by: John Sullivan <sullivan@eazel.com>
+ Fixed bug 4344 (assertion if you view a directory without a
+ metafile).
+
+ * libnautilus-extensions/nautilus-directory.c:
+ (nautilus_directory_initialize), (nautilus_directory_destroy):
+ Create and destroy the metafile hash table when the directory
+ is created and destroyed instead of waiting until the metafile
+ is read.
+
+ * libnautilus-extensions/nautilus-directory-metafile.c:
+ (get_file_node): Get rid of code to handle NULL for hash table.
+ (nautilus_directory_metafile_destroy): Just destroy the contents
+ of the hash table (hash table itself is destroyed elsewhere now).
+ (nautilus_directory_rename_file_metadata),
+ (nautilus_directory_remove_file_metadata): Get rid of code to
+ handle NULL for the hash table.
+ (nautilus_directory_set_metafile_contents): Don't create the
+ hash table any more, just populate it.
+
+2001-01-02 Darin Adler <darin@eazel.com>
+
+ reviewed by: John Sullivan <sullivan@eazel.com>
+
* src/nautilus-window-menus.c: (help_menu_about_nautilus_callback):
Added the year 2001 to the user-visible copyright notice and made it
use the standard format with the word Copyright.
diff --git a/libnautilus-extensions/nautilus-directory-metafile.c b/libnautilus-extensions/nautilus-directory-metafile.c
index f64cca3fd..a7d3fc468 100644
--- a/libnautilus-extensions/nautilus-directory-metafile.c
+++ b/libnautilus-extensions/nautilus-directory-metafile.c
@@ -104,11 +104,9 @@ get_file_node (NautilusDirectory *directory,
g_assert (NAUTILUS_IS_DIRECTORY (directory));
hash = directory->details->metafile_node_hash;
- if (hash != NULL) {
- node = g_hash_table_lookup (hash, file_name);
- if (node != NULL) {
- return node;
- }
+ node = g_hash_table_lookup (hash, file_name);
+ if (node != NULL) {
+ return node;
}
if (create) {
@@ -518,15 +516,10 @@ destroy_xml_string_key (gpointer key, gpointer value, gpointer user_data)
void
nautilus_directory_metafile_destroy (NautilusDirectory *directory)
{
- GHashTable *hash;
-
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
- hash = directory->details->metafile_node_hash;
- if (hash != NULL) {
- g_hash_table_foreach (hash, destroy_xml_string_key, NULL);
- g_hash_table_destroy (hash);
- }
+ g_hash_table_foreach (directory->details->metafile_node_hash,
+ destroy_xml_string_key, NULL);
xmlFreeDoc (directory->details->metafile);
destroy_metadata_changes_hash_table (directory->details->metadata_changes);
}
@@ -647,7 +640,7 @@ nautilus_directory_rename_file_metadata (NautilusDirectory *directory,
if (directory->details->metafile_read) {
/* Move data in XML document if present. */
hash = directory->details->metafile_node_hash;
- found = hash != NULL && g_hash_table_lookup_extended
+ found = g_hash_table_lookup_extended
(hash, old_file_name, &key, &value);
if (found) {
g_assert (strcmp (key, old_file_name) == 0);
@@ -922,7 +915,7 @@ nautilus_directory_remove_file_metadata (NautilusDirectory *directory,
if (directory->details->metafile_read) {
/* Remove data in XML document if present. */
hash = directory->details->metafile_node_hash;
- found = hash != NULL && g_hash_table_lookup_extended
+ found = g_hash_table_lookup_extended
(hash, file_name, &key, &value);
if (found) {
g_assert (strcmp (key, file_name) == 0);
@@ -966,27 +959,25 @@ nautilus_directory_set_metafile_contents (NautilusDirectory *directory,
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
g_return_if_fail (directory->details->metafile == NULL);
- g_return_if_fail (directory->details->metafile_node_hash == NULL);
- hash = g_hash_table_new (g_str_hash, g_str_equal);
+ if (metafile_contents == NULL) {
+ return;
+ }
- if (metafile_contents != NULL) {
- directory->details->metafile = metafile_contents;
-
- /* Create and populate the node hash table. */
- for (node = nautilus_xml_get_root_children (metafile_contents);
- node != NULL; node = node->next) {
- if (strcmp (node->name, "FILE") == 0) {
- name = xmlGetProp (node, "NAME");
- if (g_hash_table_lookup (hash, name) != NULL) {
- xmlFree (name);
- /* FIXME: Should we delete duplicate nodes as we discover them? */
- } else {
- g_hash_table_insert (hash, name, node);
- }
+ directory->details->metafile = metafile_contents;
+
+ /* Populate the node hash table. */
+ hash = directory->details->metafile_node_hash;
+ for (node = nautilus_xml_get_root_children (metafile_contents);
+ node != NULL; node = node->next) {
+ if (strcmp (node->name, "FILE") == 0) {
+ name = xmlGetProp (node, "NAME");
+ if (g_hash_table_lookup (hash, name) != NULL) {
+ xmlFree (name);
+ /* FIXME: Should we delete duplicate nodes as we discover them? */
+ } else {
+ g_hash_table_insert (hash, name, node);
}
}
}
-
- directory->details->metafile_node_hash = hash;
}
diff --git a/libnautilus-extensions/nautilus-directory.c b/libnautilus-extensions/nautilus-directory.c
index 8a687dbb6..9ebbf12b8 100644
--- a/libnautilus-extensions/nautilus-directory.c
+++ b/libnautilus-extensions/nautilus-directory.c
@@ -129,6 +129,7 @@ nautilus_directory_initialize (gpointer object, gpointer klass)
directory->details = g_new0 (NautilusDirectoryDetails, 1);
directory->details->file_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ directory->details->metafile_node_hash = g_hash_table_new (g_str_hash, g_str_equal);
}
void
@@ -179,19 +180,21 @@ nautilus_directory_destroy (GtkObject *object)
gtk_idle_remove (directory->details->dequeue_pending_idle_id);
}
+ nautilus_directory_metafile_destroy (directory);
+
g_free (directory->details->uri);
- if (directory->details->private_metafile_vfs_uri != NULL) {
- gnome_vfs_uri_unref (directory->details->private_metafile_vfs_uri);
- }
if (directory->details->vfs_uri != NULL) {
- gnome_vfs_uri_unref (directory->details->vfs_uri);
+ gnome_vfs_uri_unref (directory->details->vfs_uri);
}
if (directory->details->public_metafile_vfs_uri != NULL) {
gnome_vfs_uri_unref (directory->details->public_metafile_vfs_uri);
}
+ if (directory->details->private_metafile_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (directory->details->private_metafile_vfs_uri);
+ }
g_assert (directory->details->file_list == NULL);
g_hash_table_destroy (directory->details->file_hash);
- nautilus_directory_metafile_destroy (directory);
+ g_hash_table_destroy (directory->details->metafile_node_hash);
g_assert (directory->details->directory_load_in_progress == NULL);
g_assert (directory->details->count_in_progress == NULL);
g_assert (directory->details->dequeue_pending_idle_id == 0);
diff --git a/libnautilus-private/nautilus-directory-metafile.c b/libnautilus-private/nautilus-directory-metafile.c
index f64cca3fd..a7d3fc468 100644
--- a/libnautilus-private/nautilus-directory-metafile.c
+++ b/libnautilus-private/nautilus-directory-metafile.c
@@ -104,11 +104,9 @@ get_file_node (NautilusDirectory *directory,
g_assert (NAUTILUS_IS_DIRECTORY (directory));
hash = directory->details->metafile_node_hash;
- if (hash != NULL) {
- node = g_hash_table_lookup (hash, file_name);
- if (node != NULL) {
- return node;
- }
+ node = g_hash_table_lookup (hash, file_name);
+ if (node != NULL) {
+ return node;
}
if (create) {
@@ -518,15 +516,10 @@ destroy_xml_string_key (gpointer key, gpointer value, gpointer user_data)
void
nautilus_directory_metafile_destroy (NautilusDirectory *directory)
{
- GHashTable *hash;
-
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
- hash = directory->details->metafile_node_hash;
- if (hash != NULL) {
- g_hash_table_foreach (hash, destroy_xml_string_key, NULL);
- g_hash_table_destroy (hash);
- }
+ g_hash_table_foreach (directory->details->metafile_node_hash,
+ destroy_xml_string_key, NULL);
xmlFreeDoc (directory->details->metafile);
destroy_metadata_changes_hash_table (directory->details->metadata_changes);
}
@@ -647,7 +640,7 @@ nautilus_directory_rename_file_metadata (NautilusDirectory *directory,
if (directory->details->metafile_read) {
/* Move data in XML document if present. */
hash = directory->details->metafile_node_hash;
- found = hash != NULL && g_hash_table_lookup_extended
+ found = g_hash_table_lookup_extended
(hash, old_file_name, &key, &value);
if (found) {
g_assert (strcmp (key, old_file_name) == 0);
@@ -922,7 +915,7 @@ nautilus_directory_remove_file_metadata (NautilusDirectory *directory,
if (directory->details->metafile_read) {
/* Remove data in XML document if present. */
hash = directory->details->metafile_node_hash;
- found = hash != NULL && g_hash_table_lookup_extended
+ found = g_hash_table_lookup_extended
(hash, file_name, &key, &value);
if (found) {
g_assert (strcmp (key, file_name) == 0);
@@ -966,27 +959,25 @@ nautilus_directory_set_metafile_contents (NautilusDirectory *directory,
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
g_return_if_fail (directory->details->metafile == NULL);
- g_return_if_fail (directory->details->metafile_node_hash == NULL);
- hash = g_hash_table_new (g_str_hash, g_str_equal);
+ if (metafile_contents == NULL) {
+ return;
+ }
- if (metafile_contents != NULL) {
- directory->details->metafile = metafile_contents;
-
- /* Create and populate the node hash table. */
- for (node = nautilus_xml_get_root_children (metafile_contents);
- node != NULL; node = node->next) {
- if (strcmp (node->name, "FILE") == 0) {
- name = xmlGetProp (node, "NAME");
- if (g_hash_table_lookup (hash, name) != NULL) {
- xmlFree (name);
- /* FIXME: Should we delete duplicate nodes as we discover them? */
- } else {
- g_hash_table_insert (hash, name, node);
- }
+ directory->details->metafile = metafile_contents;
+
+ /* Populate the node hash table. */
+ hash = directory->details->metafile_node_hash;
+ for (node = nautilus_xml_get_root_children (metafile_contents);
+ node != NULL; node = node->next) {
+ if (strcmp (node->name, "FILE") == 0) {
+ name = xmlGetProp (node, "NAME");
+ if (g_hash_table_lookup (hash, name) != NULL) {
+ xmlFree (name);
+ /* FIXME: Should we delete duplicate nodes as we discover them? */
+ } else {
+ g_hash_table_insert (hash, name, node);
}
}
}
-
- directory->details->metafile_node_hash = hash;
}
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index 8a687dbb6..9ebbf12b8 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -129,6 +129,7 @@ nautilus_directory_initialize (gpointer object, gpointer klass)
directory->details = g_new0 (NautilusDirectoryDetails, 1);
directory->details->file_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ directory->details->metafile_node_hash = g_hash_table_new (g_str_hash, g_str_equal);
}
void
@@ -179,19 +180,21 @@ nautilus_directory_destroy (GtkObject *object)
gtk_idle_remove (directory->details->dequeue_pending_idle_id);
}
+ nautilus_directory_metafile_destroy (directory);
+
g_free (directory->details->uri);
- if (directory->details->private_metafile_vfs_uri != NULL) {
- gnome_vfs_uri_unref (directory->details->private_metafile_vfs_uri);
- }
if (directory->details->vfs_uri != NULL) {
- gnome_vfs_uri_unref (directory->details->vfs_uri);
+ gnome_vfs_uri_unref (directory->details->vfs_uri);
}
if (directory->details->public_metafile_vfs_uri != NULL) {
gnome_vfs_uri_unref (directory->details->public_metafile_vfs_uri);
}
+ if (directory->details->private_metafile_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (directory->details->private_metafile_vfs_uri);
+ }
g_assert (directory->details->file_list == NULL);
g_hash_table_destroy (directory->details->file_hash);
- nautilus_directory_metafile_destroy (directory);
+ g_hash_table_destroy (directory->details->metafile_node_hash);
g_assert (directory->details->directory_load_in_progress == NULL);
g_assert (directory->details->count_in_progress == NULL);
g_assert (directory->details->dequeue_pending_idle_id == 0);