summaryrefslogtreecommitdiff
path: root/libnautilus-extensions/nautilus-directory.c
diff options
context:
space:
mode:
authorPavel Cisler <pavel@eazel.com>2000-10-07 21:11:39 +0000
committerPavel Cisler <pce@src.gnome.org>2000-10-07 21:11:39 +0000
commit1f6c8b7bbaa355e43065178101d864a57ca8d2ba (patch)
tree7dcca11d7dfe92004a6d82c1f7c70990b13f57d5 /libnautilus-extensions/nautilus-directory.c
parent54e3f1d6916b465d4228c138a32eade5bb5aa239 (diff)
downloadnautilus-1f6c8b7bbaa355e43065178101d864a57ca8d2ba.tar.gz
Add a FIXME to some unclear or wrong code.
2000-10-07 Pavel Cisler <pavel@eazel.com> * libnautilus-extensions/nautilus-directory-async.c: (dequeue_pending_idle_callback): Add a FIXME to some unclear or wrong code. * libnautilus-extensions/nautilus-directory.c: (nautilus_directory_notify_files_added), (nautilus_directory_notify_files_removed), (nautilus_directory_notify_files_moved): Fix 3050 - Memory trashing during drag&drop. Files removed from monitored directories did get an unref but they didn't get a ref when added to new monitored directories.s Add FIXMEs to some unclear, wrong or missing code. * libnautilus-extensions/nautilus-file.c: (nautilus_file_new_from_name), (nautilus_file_new_from_info), (nautilus_file_ref), (nautilus_file_unref): Add debugging code to help find ref-counting bugs with NautilusFile. Sadly this is not the full ref/unref balance debugger I had originally in mind as it seems to be way harder to match up refs/unrefs than I thought. * libnautilus-extensions/nautilus-file.c: (nautilus_file_list_ref), (nautilus_file_list_unref), (nautilus_file_list_free), (nautilus_file_list_copy): Make these files call nautilus_file_ref/nautilus_file_unref instead of gtk_object_ref/gtk_object_unref. We should either stick to using nautilus_file_ref/unref or get rid of them. Using both pairs of calls is a mess.
Diffstat (limited to 'libnautilus-extensions/nautilus-directory.c')
-rw-r--r--libnautilus-extensions/nautilus-directory.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/libnautilus-extensions/nautilus-directory.c b/libnautilus-extensions/nautilus-directory.c
index 44c311288..60b2056c4 100644
--- a/libnautilus-extensions/nautilus-directory.c
+++ b/libnautilus-extensions/nautilus-directory.c
@@ -787,6 +787,7 @@ nautilus_directory_notify_files_added (GList *uris)
}
hash_table_list_prepend (added_lists, directory, vfs_uri);
nautilus_directory_unref (directory);
+ /* FIXME: do we need to ref here if the file is added to a monitored directory? */
}
@@ -839,6 +840,7 @@ nautilus_directory_notify_files_removed (GList *uris)
hash_table_list_prepend (changed_lists,
file->details->directory,
file);
+ /* FIXME: do we need to unref here if the file is in a monitored directory? */
}
/* Now send out the changed signals. */
@@ -858,7 +860,7 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
NautilusFile *file;
NautilusDirectory *old_directory, *new_directory;
GHashTable *parent_directories;
- GList *new_files_list, *unref_list;
+ GList *new_files_list, *unref_list, *ref_list;
GHashTable *added_lists, *changed_lists;
GList **files;
char *name;
@@ -868,6 +870,7 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
added_lists = g_hash_table_new (g_direct_hash, g_direct_equal);
changed_lists = g_hash_table_new (g_direct_hash, g_direct_equal);
unref_list = NULL;
+ ref_list = NULL;
/* Make a list of parent directories that will need their counts updated. */
parent_directories = g_hash_table_new (g_direct_hash, g_direct_equal);
@@ -878,7 +881,12 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
/* Move an existing file. */
file = nautilus_file_get (pair->from_uri);
if (file == NULL) {
- /* Handle this as it it was a new file. */
+ /* FIXME:
+ * nautilus_file_get will never return NULL
+ * what is this really trying to do?
+ */
+
+ /* Handle this as if it was a new file. */
new_files_list = g_list_prepend (new_files_list,
pair->to_uri);
} else {
@@ -927,14 +935,21 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
hash_table_list_prepend (added_lists,
new_directory,
file);
- }
- /* If the old directory was monitoring files, then it
- * may have been the only one with a ref to the file.
- */
- if (nautilus_directory_is_file_list_monitored (old_directory)) {
- unref_list = g_list_prepend (unref_list, file);
+ /* If the old directory was monitoring files, then it
+ * may have been the only one with a ref to the file.
+ */
+ if (nautilus_directory_is_file_list_monitored (old_directory)) {
+ unref_list = g_list_prepend (unref_list, file);
+ }
+ /* If the new directory is monitored, need to ref the file
+ * as it would get if it was in the directory when we started the monitor
+ */
+ if (nautilus_directory_is_file_list_monitored (new_directory)) {
+ ref_list = g_list_prepend (ref_list, file);
+ }
}
+
/* Done with the old directory. */
nautilus_directory_unref (old_directory);
@@ -950,6 +965,10 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
g_hash_table_foreach (added_lists, call_files_added_free_list, NULL);
g_hash_table_destroy (added_lists);
+ /* Ref the files we need. */
+ nautilus_file_list_ref (ref_list);
+ g_list_free (ref_list);
+
/* Let the file objects go. */
nautilus_file_list_free (unref_list);