nautilus r14736 - in trunk: . libnautilus-private



Author: alexl
Date: Fri Oct 17 17:38:31 2008
New Revision: 14736
URL: http://svn.gnome.org/viewvc/nautilus?rev=14736&view=rev

Log:
2008-10-17  Alexander Larsson  <alexl redhat com>

        * libnautilus-private/nautilus-directory-async.c:
        * libnautilus-private/nautilus-directory-private.h:
        Add nautilus_directory_has_active_request_for_file which returns true
	if monitoring or call_when_ready the file or all the files in the directory.
        * libnautilus-private/nautilus-directory.c:
        (nautilus_directory_add_file):
	When adding a file to a directory, if there is an outstanding request
	for the file, add it to the work queue so we make sure to do i/o on it.
	Otherwise we could for instance block a call_when_ready with file=NULL
	because we're waiting for something to happen on all files in the dir
	but the newly added file never has any i/o happen to it.



Modified:
   trunk/ChangeLog
   trunk/libnautilus-private/nautilus-directory-async.c
   trunk/libnautilus-private/nautilus-directory-private.h
   trunk/libnautilus-private/nautilus-directory.c

Modified: trunk/libnautilus-private/nautilus-directory-async.c
==============================================================================
--- trunk/libnautilus-private/nautilus-directory-async.c	(original)
+++ trunk/libnautilus-private/nautilus-directory-async.c	Fri Oct 17 17:38:31 2008
@@ -1964,6 +1964,36 @@
 	return found_any;
 }
 
+gboolean
+nautilus_directory_has_active_request_for_file (NautilusDirectory *directory,
+						NautilusFile *file)
+{
+	GList *node;
+	ReadyCallback *callback;
+	Monitor *monitor;
+
+	for (node = directory->details->call_when_ready_list;
+	     node != NULL; node = node->next) {
+		callback = node->data;
+		if (callback->file == file ||
+		    callback->file == NULL) {
+			return TRUE;
+		}
+	}
+
+	for (node = directory->details->monitor_list;
+	     node != NULL; node = node->next) {
+		monitor = node->data;
+		if (monitor->file == file ||
+		    monitor->file == NULL) {
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
+
 /* This checks if there's a request for monitoring the file list. */
 gboolean
 nautilus_directory_is_anyone_monitoring_file_list (NautilusDirectory *directory)

Modified: trunk/libnautilus-private/nautilus-directory-private.h
==============================================================================
--- trunk/libnautilus-private/nautilus-directory-private.h	(original)
+++ trunk/libnautilus-private/nautilus-directory-private.h	Fri Oct 17 17:38:31 2008
@@ -172,6 +172,8 @@
 void               nautilus_directory_invalidate_count_and_mime_list  (NautilusDirectory         *directory);
 gboolean           nautilus_directory_is_file_list_monitored          (NautilusDirectory         *directory);
 gboolean           nautilus_directory_is_anyone_monitoring_file_list  (NautilusDirectory         *directory);
+gboolean           nautilus_directory_has_active_request_for_file     (NautilusDirectory         *directory,
+								       NautilusFile              *file);
 void               nautilus_directory_remove_file_monitor_link        (NautilusDirectory         *directory,
 								       GList                     *link);
 void               nautilus_directory_schedule_dequeue_pending        (NautilusDirectory         *directory);

Modified: trunk/libnautilus-private/nautilus-directory.c
==============================================================================
--- trunk/libnautilus-private/nautilus-directory.c	(original)
+++ trunk/libnautilus-private/nautilus-directory.c	Fri Oct 17 17:38:31 2008
@@ -633,6 +633,7 @@
 nautilus_directory_add_file (NautilusDirectory *directory, NautilusFile *file)
 {
 	GList *node;
+	gboolean add_to_work_queue;
 
 	g_assert (NAUTILUS_IS_DIRECTORY (directory));
 	g_assert (NAUTILUS_IS_FILE (file));
@@ -647,9 +648,19 @@
 
 	directory->details->confirmed_file_count++;
 
-	/* Ref if we are monitoring. */
+	add_to_work_queue = FALSE;
 	if (nautilus_directory_is_file_list_monitored (directory)) {
+		/* Ref if we are monitoring, since monitoring owns the file list. */
 		nautilus_file_ref (file);
+		add_to_work_queue = TRUE;
+	} else if (nautilus_directory_has_active_request_for_file (directory, file)) {
+		/* We're waiting for the file in a call_when_ready. Make sure
+		   we add the file to the work queue so that said waiter won't
+		   wait forever for e.g. all files in the directory to be done */
+		add_to_work_queue = TRUE;
+	}
+	
+	if (add_to_work_queue) {
 		nautilus_directory_add_file_to_work_queue (directory, file);
 	}
 }



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