summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-2000041422
-rw-r--r--libnautilus-extensions/nautilus-directory-private.h3
-rw-r--r--libnautilus-extensions/nautilus-directory.c39
-rw-r--r--libnautilus-extensions/nautilus-file.c82
-rw-r--r--libnautilus-extensions/nautilus-lib-self-check-functions.h1
-rw-r--r--libnautilus-private/nautilus-directory-private.h3
-rw-r--r--libnautilus-private/nautilus-directory.c39
-rw-r--r--libnautilus-private/nautilus-file.c82
-rw-r--r--libnautilus-private/nautilus-lib-self-check-functions.h1
-rw-r--r--libnautilus/nautilus-directory-private.h3
-rw-r--r--libnautilus/nautilus-directory.c39
-rw-r--r--libnautilus/nautilus-file.c82
-rw-r--r--libnautilus/nautilus-lib-self-check-functions.h1
13 files changed, 301 insertions, 96 deletions
diff --git a/ChangeLog-20000414 b/ChangeLog-20000414
index a4368ff40..ef693e2e2 100644
--- a/ChangeLog-20000414
+++ b/ChangeLog-20000414
@@ -1,3 +1,25 @@
+2000-03-09 John Sullivan <sullivan@eazel.com>
+
+ * libnautilus/nautilus-directory-private.h:
+ (nautilus_directory_number_outstanding): Added prototype for this
+ debugging function.
+ * libnautilus/nautilus-directory.c:
+ (nautilus_directory_number_outstanding): New debugging function,
+ used in NautilusFile self-checks.
+ (nautilus_self_check_directory): Pulled out the NautilusFile tests
+ to move them to nautilus-file.c.
+ * libnautilus/nautilus-file.c:
+ (nautilus_file_unref): Move gtk_object_unref after
+ nautilus_file_free call. Darin noticed this bug while reading
+ the code with me.
+ (nautilus_file_list_unref): Made this unref instead of ref. Oops!
+ This was causing NautilusDirectory objects never to go away after
+ visiting a directory; now they're destroyed when you leave.
+ (nautilus_self_check_file): New function, some of this was moved
+ over from nautilus-directory.c, and I added some ref-count checks.
+ * libnautilus/nautilus-lib-self-check-functions.h:
+ Included nautilus_self_check_file in list of self-check functions.
+
2000-03-09 Andy Hertzfeld <andy@eazel.com>
* libnautilus/nautilus-icons-view-icon-item.c:
diff --git a/libnautilus-extensions/nautilus-directory-private.h b/libnautilus-extensions/nautilus-directory-private.h
index e4acddba1..6e815554c 100644
--- a/libnautilus-extensions/nautilus-directory-private.h
+++ b/libnautilus-extensions/nautilus-directory-private.h
@@ -76,3 +76,6 @@ void nautilus_directory_files_changed (NautilusDirectory *dire
void nautilus_directory_files_removed (NautilusDirectory *directory,
GList *removed_files);
void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
+
+/* debugging functions */
+int nautilus_directory_number_outstanding (void);
diff --git a/libnautilus-extensions/nautilus-directory.c b/libnautilus-extensions/nautilus-directory.c
index 674dcf402..1f92ad36b 100644
--- a/libnautilus-extensions/nautilus-directory.c
+++ b/libnautilus-extensions/nautilus-directory.c
@@ -1137,12 +1137,17 @@ get_files_cb (NautilusDirectory *directory, GList *files, gpointer data)
file_count += g_list_length (files);
}
+/* Return the number of extant NautilusDirectories */
+int
+nautilus_directory_number_outstanding ()
+{
+ return g_hash_table_size (directory_objects);
+}
+
void
nautilus_self_check_directory (void)
{
NautilusDirectory *directory;
- NautilusFile *file_1;
- NautilusFile *file_2;
directory = nautilus_directory_get ("file:///etc");
@@ -1195,34 +1200,6 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_get_metadata (directory, "TEST", "default"), "value");
- file_1 = nautilus_file_get ("file:///home/");
-
- NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
-
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home/") == file_1, TRUE);
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home") == file_1, TRUE);
- nautilus_file_unref (file_1);
-
- nautilus_file_unref (file_1);
-
- file_1 = nautilus_file_get ("file:///home");
- NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
- nautilus_file_unref (file_1);
-
- /* sorting */
- file_1 = nautilus_file_get ("file:///etc");
- file_2 = nautilus_file_get ("file:///usr");
-
- NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
- NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 1);
-
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) < 0, TRUE);
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort_reversed (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) > 0, TRUE);
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_1, NAUTILUS_FILE_SORT_BY_NAME) == 0, TRUE);
-
- nautilus_file_unref (file_1);
- nautilus_file_unref (file_2);
-
/* nautilus_directory_escape_slashes */
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes (""), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a"), "a");
@@ -1232,6 +1209,8 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a%a"), "a%25a");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%25"), "%2525");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%2F"), "%252F");
+
+ gtk_object_unref (GTK_OBJECT (directory));
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-extensions/nautilus-file.c b/libnautilus-extensions/nautilus-file.c
index e758c4720..99966b0fd 100644
--- a/libnautilus-extensions/nautilus-file.c
+++ b/libnautilus-extensions/nautilus-file.c
@@ -32,6 +32,7 @@
#include <libgnome/gnome-i18n.h>
#include "nautilus-glib-extensions.h"
+#include "nautilus-lib-self-check-functions.h"
#include "nautilus-string.h"
#include "nautilus-directory-private.h"
@@ -158,10 +159,10 @@ nautilus_file_unref (NautilusFile *file)
}
/* No references left, so it's time to release our hold on the directory. */
- gtk_object_unref (GTK_OBJECT (file->directory));
if (file->is_gone) {
nautilus_file_free (file);
}
+ gtk_object_unref (GTK_OBJECT (file->directory));
}
void
@@ -1086,7 +1087,7 @@ nautilus_file_list_ref (GList *file_list)
void
nautilus_file_list_unref (GList *file_list)
{
- g_list_foreach (file_list, (GFunc) nautilus_file_ref, NULL);
+ g_list_foreach (file_list, (GFunc) nautilus_file_unref, NULL);
}
/**
@@ -1101,3 +1102,80 @@ nautilus_file_list_free (GList *file_list)
nautilus_file_list_unref (file_list);
g_list_free (file_list);
}
+
+#if !defined (NAUTILUS_OMIT_SELF_CHECK)
+
+void
+nautilus_self_check_file (void)
+{
+ NautilusFile *file_1;
+ NautilusFile *file_2;
+ GList *list;
+
+ /* refcount checks */
+
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
+
+ file_1 = nautilus_file_get ("file:///home/");
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (GTK_OBJECT (file_1->directory)->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 1);
+
+ nautilus_file_unref (file_1);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
+
+ file_1 = nautilus_file_get ("file:///etc");
+ file_2 = nautilus_file_get ("file:///usr");
+
+ list = NULL; /* let's be explicit here */
+ list = g_list_append (list, file_1);
+ list = g_list_append (list, file_2);
+
+ nautilus_file_list_ref (list);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 2);
+ NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 2);
+
+ nautilus_file_list_unref (list);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 1);
+
+ nautilus_file_list_free (list);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
+
+
+ /* name checks */
+ file_1 = nautilus_file_get ("file:///home/");
+
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
+
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home/") == file_1, TRUE);
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home") == file_1, TRUE);
+
+ nautilus_file_unref (file_1);
+ nautilus_file_unref (file_1);
+
+ file_1 = nautilus_file_get ("file:///home");
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
+ nautilus_file_unref (file_1);
+
+ /* sorting */
+ file_1 = nautilus_file_get ("file:///etc");
+ file_2 = nautilus_file_get ("file:///usr");
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 1);
+
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) < 0, TRUE);
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort_reversed (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) > 0, TRUE);
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_1, NAUTILUS_FILE_SORT_BY_NAME) == 0, TRUE);
+
+ nautilus_file_unref (file_1);
+ nautilus_file_unref (file_2);
+}
+
+#endif /* !NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-extensions/nautilus-lib-self-check-functions.h b/libnautilus-extensions/nautilus-lib-self-check-functions.h
index 555ace21b..581637aa7 100644
--- a/libnautilus-extensions/nautilus-lib-self-check-functions.h
+++ b/libnautilus-extensions/nautilus-lib-self-check-functions.h
@@ -44,6 +44,7 @@ void nautilus_run_lib_self_checks (void);
macro (nautilus_self_check_gdk_extensions) \
macro (nautilus_self_check_background) \
macro (nautilus_self_check_directory) \
+ macro (nautilus_self_check_file) \
macro (nautilus_self_check_gnome_icon_container) \
macro (nautilus_self_check_icon_factory) \
/* Add new self-check functions to the list above this line. */
diff --git a/libnautilus-private/nautilus-directory-private.h b/libnautilus-private/nautilus-directory-private.h
index e4acddba1..6e815554c 100644
--- a/libnautilus-private/nautilus-directory-private.h
+++ b/libnautilus-private/nautilus-directory-private.h
@@ -76,3 +76,6 @@ void nautilus_directory_files_changed (NautilusDirectory *dire
void nautilus_directory_files_removed (NautilusDirectory *directory,
GList *removed_files);
void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
+
+/* debugging functions */
+int nautilus_directory_number_outstanding (void);
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index 674dcf402..1f92ad36b 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -1137,12 +1137,17 @@ get_files_cb (NautilusDirectory *directory, GList *files, gpointer data)
file_count += g_list_length (files);
}
+/* Return the number of extant NautilusDirectories */
+int
+nautilus_directory_number_outstanding ()
+{
+ return g_hash_table_size (directory_objects);
+}
+
void
nautilus_self_check_directory (void)
{
NautilusDirectory *directory;
- NautilusFile *file_1;
- NautilusFile *file_2;
directory = nautilus_directory_get ("file:///etc");
@@ -1195,34 +1200,6 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_get_metadata (directory, "TEST", "default"), "value");
- file_1 = nautilus_file_get ("file:///home/");
-
- NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
-
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home/") == file_1, TRUE);
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home") == file_1, TRUE);
- nautilus_file_unref (file_1);
-
- nautilus_file_unref (file_1);
-
- file_1 = nautilus_file_get ("file:///home");
- NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
- nautilus_file_unref (file_1);
-
- /* sorting */
- file_1 = nautilus_file_get ("file:///etc");
- file_2 = nautilus_file_get ("file:///usr");
-
- NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
- NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 1);
-
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) < 0, TRUE);
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort_reversed (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) > 0, TRUE);
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_1, NAUTILUS_FILE_SORT_BY_NAME) == 0, TRUE);
-
- nautilus_file_unref (file_1);
- nautilus_file_unref (file_2);
-
/* nautilus_directory_escape_slashes */
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes (""), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a"), "a");
@@ -1232,6 +1209,8 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a%a"), "a%25a");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%25"), "%2525");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%2F"), "%252F");
+
+ gtk_object_unref (GTK_OBJECT (directory));
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index e758c4720..99966b0fd 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -32,6 +32,7 @@
#include <libgnome/gnome-i18n.h>
#include "nautilus-glib-extensions.h"
+#include "nautilus-lib-self-check-functions.h"
#include "nautilus-string.h"
#include "nautilus-directory-private.h"
@@ -158,10 +159,10 @@ nautilus_file_unref (NautilusFile *file)
}
/* No references left, so it's time to release our hold on the directory. */
- gtk_object_unref (GTK_OBJECT (file->directory));
if (file->is_gone) {
nautilus_file_free (file);
}
+ gtk_object_unref (GTK_OBJECT (file->directory));
}
void
@@ -1086,7 +1087,7 @@ nautilus_file_list_ref (GList *file_list)
void
nautilus_file_list_unref (GList *file_list)
{
- g_list_foreach (file_list, (GFunc) nautilus_file_ref, NULL);
+ g_list_foreach (file_list, (GFunc) nautilus_file_unref, NULL);
}
/**
@@ -1101,3 +1102,80 @@ nautilus_file_list_free (GList *file_list)
nautilus_file_list_unref (file_list);
g_list_free (file_list);
}
+
+#if !defined (NAUTILUS_OMIT_SELF_CHECK)
+
+void
+nautilus_self_check_file (void)
+{
+ NautilusFile *file_1;
+ NautilusFile *file_2;
+ GList *list;
+
+ /* refcount checks */
+
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
+
+ file_1 = nautilus_file_get ("file:///home/");
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (GTK_OBJECT (file_1->directory)->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 1);
+
+ nautilus_file_unref (file_1);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
+
+ file_1 = nautilus_file_get ("file:///etc");
+ file_2 = nautilus_file_get ("file:///usr");
+
+ list = NULL; /* let's be explicit here */
+ list = g_list_append (list, file_1);
+ list = g_list_append (list, file_2);
+
+ nautilus_file_list_ref (list);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 2);
+ NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 2);
+
+ nautilus_file_list_unref (list);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 1);
+
+ nautilus_file_list_free (list);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
+
+
+ /* name checks */
+ file_1 = nautilus_file_get ("file:///home/");
+
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
+
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home/") == file_1, TRUE);
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home") == file_1, TRUE);
+
+ nautilus_file_unref (file_1);
+ nautilus_file_unref (file_1);
+
+ file_1 = nautilus_file_get ("file:///home");
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
+ nautilus_file_unref (file_1);
+
+ /* sorting */
+ file_1 = nautilus_file_get ("file:///etc");
+ file_2 = nautilus_file_get ("file:///usr");
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 1);
+
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) < 0, TRUE);
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort_reversed (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) > 0, TRUE);
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_1, NAUTILUS_FILE_SORT_BY_NAME) == 0, TRUE);
+
+ nautilus_file_unref (file_1);
+ nautilus_file_unref (file_2);
+}
+
+#endif /* !NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-private/nautilus-lib-self-check-functions.h b/libnautilus-private/nautilus-lib-self-check-functions.h
index 555ace21b..581637aa7 100644
--- a/libnautilus-private/nautilus-lib-self-check-functions.h
+++ b/libnautilus-private/nautilus-lib-self-check-functions.h
@@ -44,6 +44,7 @@ void nautilus_run_lib_self_checks (void);
macro (nautilus_self_check_gdk_extensions) \
macro (nautilus_self_check_background) \
macro (nautilus_self_check_directory) \
+ macro (nautilus_self_check_file) \
macro (nautilus_self_check_gnome_icon_container) \
macro (nautilus_self_check_icon_factory) \
/* Add new self-check functions to the list above this line. */
diff --git a/libnautilus/nautilus-directory-private.h b/libnautilus/nautilus-directory-private.h
index e4acddba1..6e815554c 100644
--- a/libnautilus/nautilus-directory-private.h
+++ b/libnautilus/nautilus-directory-private.h
@@ -76,3 +76,6 @@ void nautilus_directory_files_changed (NautilusDirectory *dire
void nautilus_directory_files_removed (NautilusDirectory *directory,
GList *removed_files);
void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
+
+/* debugging functions */
+int nautilus_directory_number_outstanding (void);
diff --git a/libnautilus/nautilus-directory.c b/libnautilus/nautilus-directory.c
index 674dcf402..1f92ad36b 100644
--- a/libnautilus/nautilus-directory.c
+++ b/libnautilus/nautilus-directory.c
@@ -1137,12 +1137,17 @@ get_files_cb (NautilusDirectory *directory, GList *files, gpointer data)
file_count += g_list_length (files);
}
+/* Return the number of extant NautilusDirectories */
+int
+nautilus_directory_number_outstanding ()
+{
+ return g_hash_table_size (directory_objects);
+}
+
void
nautilus_self_check_directory (void)
{
NautilusDirectory *directory;
- NautilusFile *file_1;
- NautilusFile *file_2;
directory = nautilus_directory_get ("file:///etc");
@@ -1195,34 +1200,6 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_get_metadata (directory, "TEST", "default"), "value");
- file_1 = nautilus_file_get ("file:///home/");
-
- NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
-
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home/") == file_1, TRUE);
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home") == file_1, TRUE);
- nautilus_file_unref (file_1);
-
- nautilus_file_unref (file_1);
-
- file_1 = nautilus_file_get ("file:///home");
- NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
- nautilus_file_unref (file_1);
-
- /* sorting */
- file_1 = nautilus_file_get ("file:///etc");
- file_2 = nautilus_file_get ("file:///usr");
-
- NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
- NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 1);
-
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) < 0, TRUE);
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort_reversed (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) > 0, TRUE);
- NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_1, NAUTILUS_FILE_SORT_BY_NAME) == 0, TRUE);
-
- nautilus_file_unref (file_1);
- nautilus_file_unref (file_2);
-
/* nautilus_directory_escape_slashes */
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes (""), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a"), "a");
@@ -1232,6 +1209,8 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a%a"), "a%25a");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%25"), "%2525");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%2F"), "%252F");
+
+ gtk_object_unref (GTK_OBJECT (directory));
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus/nautilus-file.c b/libnautilus/nautilus-file.c
index e758c4720..99966b0fd 100644
--- a/libnautilus/nautilus-file.c
+++ b/libnautilus/nautilus-file.c
@@ -32,6 +32,7 @@
#include <libgnome/gnome-i18n.h>
#include "nautilus-glib-extensions.h"
+#include "nautilus-lib-self-check-functions.h"
#include "nautilus-string.h"
#include "nautilus-directory-private.h"
@@ -158,10 +159,10 @@ nautilus_file_unref (NautilusFile *file)
}
/* No references left, so it's time to release our hold on the directory. */
- gtk_object_unref (GTK_OBJECT (file->directory));
if (file->is_gone) {
nautilus_file_free (file);
}
+ gtk_object_unref (GTK_OBJECT (file->directory));
}
void
@@ -1086,7 +1087,7 @@ nautilus_file_list_ref (GList *file_list)
void
nautilus_file_list_unref (GList *file_list)
{
- g_list_foreach (file_list, (GFunc) nautilus_file_ref, NULL);
+ g_list_foreach (file_list, (GFunc) nautilus_file_unref, NULL);
}
/**
@@ -1101,3 +1102,80 @@ nautilus_file_list_free (GList *file_list)
nautilus_file_list_unref (file_list);
g_list_free (file_list);
}
+
+#if !defined (NAUTILUS_OMIT_SELF_CHECK)
+
+void
+nautilus_self_check_file (void)
+{
+ NautilusFile *file_1;
+ NautilusFile *file_2;
+ GList *list;
+
+ /* refcount checks */
+
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
+
+ file_1 = nautilus_file_get ("file:///home/");
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (GTK_OBJECT (file_1->directory)->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 1);
+
+ nautilus_file_unref (file_1);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
+
+ file_1 = nautilus_file_get ("file:///etc");
+ file_2 = nautilus_file_get ("file:///usr");
+
+ list = NULL; /* let's be explicit here */
+ list = g_list_append (list, file_1);
+ list = g_list_append (list, file_2);
+
+ nautilus_file_list_ref (list);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 2);
+ NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 2);
+
+ nautilus_file_list_unref (list);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 1);
+
+ nautilus_file_list_free (list);
+
+ NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
+
+
+ /* name checks */
+ file_1 = nautilus_file_get ("file:///home/");
+
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
+
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home/") == file_1, TRUE);
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home") == file_1, TRUE);
+
+ nautilus_file_unref (file_1);
+ nautilus_file_unref (file_1);
+
+ file_1 = nautilus_file_get ("file:///home");
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
+ nautilus_file_unref (file_1);
+
+ /* sorting */
+ file_1 = nautilus_file_get ("file:///etc");
+ file_2 = nautilus_file_get ("file:///usr");
+
+ NAUTILUS_CHECK_INTEGER_RESULT (file_1->ref_count, 1);
+ NAUTILUS_CHECK_INTEGER_RESULT (file_2->ref_count, 1);
+
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) < 0, TRUE);
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort_reversed (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) > 0, TRUE);
+ NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_1, NAUTILUS_FILE_SORT_BY_NAME) == 0, TRUE);
+
+ nautilus_file_unref (file_1);
+ nautilus_file_unref (file_2);
+}
+
+#endif /* !NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus/nautilus-lib-self-check-functions.h b/libnautilus/nautilus-lib-self-check-functions.h
index 555ace21b..581637aa7 100644
--- a/libnautilus/nautilus-lib-self-check-functions.h
+++ b/libnautilus/nautilus-lib-self-check-functions.h
@@ -44,6 +44,7 @@ void nautilus_run_lib_self_checks (void);
macro (nautilus_self_check_gdk_extensions) \
macro (nautilus_self_check_background) \
macro (nautilus_self_check_directory) \
+ macro (nautilus_self_check_file) \
macro (nautilus_self_check_gnome_icon_container) \
macro (nautilus_self_check_icon_factory) \
/* Add new self-check functions to the list above this line. */